Denominations - 3
Write a program to find the minimum number of notes required for the amount M. Available note denominations are 500, 50, 10, 1.
Input
The first line is a single integer M.
Output
Print M in denominaitons.
Explanation
Given
M = 1543, it can be written as1543 = 3*(500) + 3*(50) + 0*(10) + 1*(3)Then the output should be
500: 3 50: 0 10: 4 1: 3
Sample Input 1
1543
Sample Output 1
500: 3 50: 0 10: 4 1: 3
Sample Input 2
1259
Sample Output 2
500: 2 50: 5 10: 0 1: 9
n = int(input())
print(f'500: {n // 500}', end=' ')
n = n % 500
print(f'50: {n // 50}', end=' ')
n = n % 50
print(f'10: {n // 10} 1: {n % 10}')
Comments
Leave a comment