atcoder#ABC270E. [ABC270E] Apple Baskets on Circle
[ABC270E] Apple Baskets on Circle
Score : points
Problem Statement
There are baskets numbered arranged in a circle. For each , basket is to the immediate right of basket , and basket is to the immediate right of basket .
Basket now contains apples.
Takahashi starts in front of basket and repeats the following action.
- If the basket he is facing contains an apple, take one and eat it. Then, regardless of whether he has eaten an apple now, go on to the next basket to the immediate right.
Find the number of apples remaining in each basket when Takahashi has eaten exactly apples in total.
Constraints
- There are at least apples in total. That is, .
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print integers, with spaces in between. The -th integer should be the number of apples remaining in basket when Takahashi has eaten exactly apples in total.
3 3
1 3 0
0 1 0
Takahashi will do the following.
- Basket , which he is facing, contains an apple, so he takes one and eats it. Then, he goes on to basket . Now, the baskets have apples.
- Basket , which he is facing, contains an apple, so he takes one and eats it. Then, he goes on to basket . Now, the baskets have apples.
- Basket , which he is facing, contains no apple. Then, he goes on to basket . Now, the baskets have apples.
- Basket , which he is facing, contains no apple. Then, he goes on to basket . Now, the baskets have apples.
- Basket , which he is facing, contains an apple, so he takes one and eats it. Then, he goes on to basket . Now, the baskets have apple(s).
2 1000000000000
1000000000000 1000000000000
500000000000 500000000000