New update is available. Click here to update.

Find Minimum Number Of Coins

Posted: 9 Dec, 2020
Difficulty: Easy


Try Problem

Dora, the explorer, visits India and decides to try the famous Indian food. However, the restaurant accepts only Indian currency i.e. [1, 2, 5, 10, 20, 50, 100, 500, 1000] valued coins.

So, Dora goes to a bank that has an infinite supply of each of the denominations to make a change for a given ‘Amount’ of money. As a cashier at the bank, your task is to provide Dora the minimum number of coins that add up to the given ‘Amount’.

For Example
For Amount = 70, the minimum number of coins required is 2 i.e an Rs. 50 coin and a Rs. 20 coin.
It is always possible to find the minimum number of coins for the given amount. So, the answer will always exist.
Input Format
The first line of input contains an integer 'T' representing the number of test cases or queries to be processed. Then the test case follows.

The only line of each test case contains a single integer ‘Amount’ representing the amount Dora wishes to change to Indian currency.
Output Format
For each test case, print the minimum number of coins needed to make the change.

Print the output of each test case in a separate line.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 100
1 <= Amount <= 10^5
Where 'T' is the number of test-cases
Time Limit: 1sec