Denominations - 4
Write a program to find the minimum number of notes required for the amount
The first line is a single integer
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.
nominals = (2000, 500, 200, 50, 20, 5, 2, 1)
amount = int(input('amount = '))
output = {}
for n in nominals:
output[n] = amount //n
amount %= n
for k, v in output.items():
print(k, v, sep=':', end=" ")
print()
Comments
Leave a comment