TORONTO KIDS COMPUTER CLUB | Aurora Saturday 14:30 Python Practice 22.08.13.
20972
post-template-default,single,single-post,postid-20972,single-format-standard,ajax_fade,page_not_loaded,,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.10.0,vc_responsive

Aurora Saturday 14:30 Python Practice 22.08.13.

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

No Comments

Sorry, the comment form is closed at this time.