Minimum number of Coins
Submissions: 16462   Accuracy:


  Difficulty: Easy   Marks: 2

Given a value N, total sum you have. You have to make change for Rs. N, and there is infinite supply of each of the denominations in Indian currency, i.e., you have infinite supply of { 1, 2, 5, 10, 20, 50, 100, 200, 500, 2000} valued coins/notes, Find the minimum number of coins and/or notes needed to make the change for Rs N.

The first line of input contains an integer T denoting the number of test cases. Each test case consist of an Integer value N denoting the amount to get change for.

Print all the denominations needed to make the change in a separate line.

1 ≤ T ≤ 100
1 ≤ N ≤ 106


20 20 2 1

Testcase 1:
Sum of Rs 43 can be changed with minimum of 4 coins/ notes 20, 20, 2, 1.


** For More Input/Output Examples Use 'Expected Output' option **

Author: shef5

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Need help with your code? Please use, generate link and share the link here.

to report an issue on this page.