#ABC475B. 找零 / Change
找零 / Change
Problem Statement
In the Kingdom of AtCoder, three kinds of coins — -yen coins, -yen coins, and -yen coins — and -yen bills are in circulation.
Takahashi made purchases, starting from a state where he had -yen bills and coins.
In the -th purchase, he bought an item worth yen. For the payment, he paid using only the minimum number of -yen bills such that the total amount paid was at least yen, and received the change so that the total number of coins received as change was minimized.
Find the number of each type of coin that Takahashi has at the point when all purchases are finished.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Output the number of -yen coins, -yen coins, and -yen coins that Takahashi has at the point when the purchases are finished, in this order, separated by spaces.
3
1296 110 1
13 18 24
In the first purchase, for the payment of yen, Takahashi pays with two -yen bills, and receives seven -yen coins and four -yen coins as change.
In the second purchase, for the payment of yen, he pays with one -yen bill, and receives eight -yen coins and nine -yen coins as change.
In the third purchase, for the payment of yen, he pays with one -yen bill, and receives nine -yen coins, nine -yen coins, and nine -yen coins as change.
At the point when the three purchases are finished, he has -yen coins, -yen coins, and -yen coins.
12
3141 592 65358 9 79 323 84 6264 3 38327 950 28
52 59 82
- Source: AtCoder ABC 475 B
相关
在下列比赛中: