
ZOJ Problem Set  2156
Charlie is a driver of Advanced Cargo Movement, Ltd. Charlie drives a lot and so he often buys coffee at coffee vending machines at motorests. Charlie hates change. That is basically the setup of your next task. Your program will be given numbers and types of coins Charlie has and the coffee price. The coffee vending machines accept coins of values 1, 5, 10, and 25 cents. The program should output which coins Charlie has to use paying the coffee so that he uses as many coins as possible. Because Charlie really does not want any change back he wants to pay the price exactly.
Input SpecificationEach line of the input contains five integer numbers separated by a single space describing one situation to solve. The first integer on the line P, 1 P 10 000, is the coffee price in cents. Next four integers, C_{1}, C_{2}, C_{3}, C_{4}, 0 C_{i} 10 000, are the numbers of cents, nickels (5 cents), dimes (10 cents), and quarters (25 cents) in Charlie's valet. The last line of the input contains five zeros and no output should be generated for it.
Output SpecificationFor each situation, your program should output one line containing the string "Throw in T1 cents, T2 nickels, T3 dimes, and T4 quarters.", where T_{1}, T_{2}, T_{3}, T_{4} are the numbers of coins of appropriate values Charlie should use to pay the coffee while using as many coins as possible. In the case Charlie does not possess enough change to pay the price of the coffee exactly, your program should output "Charlie cannot buy coffee.".
Sample Input12 5 3 1 2 16 0 0 0 1 0 0 0 0 0
Sample OutputThrow in 2 cents, 2 nickels, 0 dimes, and 0 quarters. Charlie cannot buy coffee.
Source: Czech Technical University Open 2003 