Denominations - 4
Write a program to find the minimum number of notes required for the amount M. Available note denominations are 2000, 500, 200, 50, 20, 5, 2, 1.Input
The first line is a single integer M.
Output
Print M in denominations.
Explanation
Given
M = 2257 Then 2257 can be written as
2000 * 1 + 500 * 0 + 200 * 1 + 50 * 1 + 20 * 0 + 5 * 1 + 2 * 1 + 1 * 0So the output should be
2000:1 500:0 200:1 50:1 20:0 5:1 2:1 1:0.
Sample Input 1
2257
Sample Output 1
2000:1 500:0 200:1 50:1 20:0 5:1 2:1 1:0
Sample Input 2
2345
Sample Output 2
2000:1 500:0 200:1 50:2 20:2 5:1 2:0 1:0
M = int(input())
denominations = [2000, 500, 200, 50, 20, 5, 2, 1]
for denomination in denominations:
print(denomination, ':', M//denomination, sep='', end=' ')
M -= M//denomination * denomination
print()
Comments
Leave a comment