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.
M = int(input())
D=2000
print(D, ':', M//D, sep='', end=' ')
M -= M//D * D
D=500
print(D, ':', M//D, sep='', end=' ')
M -= M//D * D
D=200
print(D, ':', M//D, sep='', end=' ')
M -= M//D * D
D=50
print(D, ':', M//D, sep='', end=' ')
M -= M//D * D
D=20
print(D, ':', M//D, sep='', end=' ')
M -= M//D * D
D=5
print(D, ':', M//D, sep='', end=' ')
M -= M//D * D
D=2
print(D, ':', M//D, sep='', end=' ')
M -= M//D * D
D=1
print(D, ':', M//D, sep='', end=' ')
M -= M//D * D
Comments
Leave a comment