100 atcoder#ABC208C. [ABC208C] Fair Candy Distribution
[ABC208C] Fair Candy Distribution
Score : points
Problem Statement
There are citizens in the Kingdom of Takahashi. Each citizen has a national ID number; the ID of the -th citizen is . Here, all are pairwise different.
Takahashi has pieces of sweets. He has decided to hand out these pieces to the citizens in the following way until he has no more pieces.
- When he has or more pieces, hand out one piece to every citizen.
- Otherwise, let be the number of pieces he has at the moment, and hand out one piece to each of the citizens with the smallest IDs.
When all pieces are handed out, how many pieces will the -th citizen have?
Constraints
- All are pairwise different.
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print lines. The -th line should contain the number of pieces of sweets received by the -th citizen.
2 7
1 8
4
3
Takahashi will hand out the pieces as follows.
- Hand out one piece to everyone, leaving Takhashi with pieces.
- Hand out one piece to everyone, leaving Takhashi with pieces.
- Hand out one piece to everyone, leaving Takhashi with piece.
- Hand out one piece to the -st citizen, leaving Takhashi with no pieces.
In the end, the -st citizen will receive pieces, and the -nd citizen will receive pieces.
1 3
33
3
Since there is just one citizen, Takahashi will hand out all pieces to that -st citizen.
7 1000000000000
99 8 2 4 43 5 3
142857142857
142857142857
142857142858
142857142857
142857142857
142857142857
142857142857