| Problem ID | 1115 |
|---|---|
| Title | Cashier |
| Description | Bob is working at a cashier counter, he needs to make hundreds of changes everyday. But he is very laze and does not want to count how many and which types of banknotes he needs to change. So he asked you to write a program, which take in the amount of money customer paid, the price of goods bought, and then output numbers of each banknote to give back.
Available coins and banknotes are $1, $2, $5, $10, $20, $50, $100, $500, $1000. You have to always use the largest value you can. But since $1000 is the largest valued banknote, you will not need to consider $1000 (you will only receive but not give out $1000). |
| Input | The first line is the number of customers, N, 1 ≤ N ≤ 100.
And then there will be N lines, each line has 2 integers. The first integer is the paid amount A, and the second integer is the total price P. Two integers are separated by a space. 1 ≤ A, P ≤ 30000. |
| Output | Print N lines of 8 integers. Each line represents the changes to one customer.
From left to right, is the numbers of $500, $100, $50, $20, ......from larger value to smaller value. |
| Sample Input | 3 100 87 500 322 1000 501 |
| Sample Output | 0 0 0 0 1 0 1 1 0 1 1 1 0 1 1 1 0 4 1 2 0 1 2 0 |
| Hint | Quotient and remainder. |
| Last Modified | 2012-10-27 09:32:28 |
| Time Limit | 1 seconds |
| Memory Limit | 64 MB |
| Accepted Solutions | 0 |
| Submitted Solutions | 3 |
| Difficulty Factor | 537 |
Facebook