18 Aug Aurora Saturday 14:30 Python Practice 22.08.13.
Question:
Jack save money by using piggy bank, he has many coins valued 1 cent, 5 cents, 10 cents, 50 cents and 1 dollar(100 cents) in the piggy bank.
Now Jack has a book to buy, it costs P cents. He wonders how many coins at least,and how many coins at most he can use to buy this nice book. Jack is a bit strange, he doesn’t like to get the change, that is, he will give the bookseller exactly P cents.
Input
T(T<=100) in the first line, indicating the case number.
T lines with 6 integers each:
P a1 a5 a10 a50 a100
ai means number of i-cents coin.
All integers are smaller than 1000000.
Output
Two integers A,B for each case, A is the fewest number of coins to buy the book exactly, and B is the largest number to buy exactly. If Jack can’t buy the book with no change, output “-1 -1”.
Sample Input
3
33 6 6 6 6 6
10 10 10 10 10 10
11 0 1 20 20 20
Sample Output
6 9
1 10
-1 -1
Sorry, the comment form is closed at this time.