Text from the official booklet. Refer to the PDF for original mathematical notation, formatting, and linked input files. Printed samples and inputs are reproduced as published.
A scientist is experimenting with liquid mixtures using three containers of different capacities. Each container initially holds a certain amount of liquid, but they are not necessarily full. The scientist performs a sequence of transfers in a cyclic manner: Pouring from container 1 into container 2 Pouring from container 2 into container 3 Pouring from container 3 into container 1 This process repeats for a total of 100 pours (so the 100th pour would be from container 1 into container 2). Each time, the scientist transfers as much liquid as possible from one container to the next, stopping when either the source container is empty or the destination container is full. Your task is to determine how much liquid remains in each container after all 100 pours. The first line of the input file contains two space-separated integers: the capacity c1 of the first bucket, and the amount of milk m1 in the first bucket. Both c1 and m1 are positive and at most 1 billion, with c1 ≥ m1. The second and third lines are similar, containing capacities and milk amounts for the second and third buckets. Please print three lines of output, giving the final amount of milk in each bucket, after 100 pour operations. SAMPLE INPUT: 10 3 11 4 12 5 SAMPLE OUTPUT: 0 10 2 Input Case 1: 695789 393585 705404 502652 999933 95061 Case 2: 855636227 749698587 687926653 660260757 959997302 485560281