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
m = int(input())
line = ''
count1 = m // 500
count2 = (m - 500 * count1) // 50
count3 = (m - 500 * count1 - 50 * count2) // 10
count4 = (m - 500 * count1 - 50 * count2 - 10 * count3) // 1
line += f'500: {count1} '
line += f'50: {count2} '
line += f'10: {count3} '
line += f'1: {count4} '
print(line)
Comments
Leave a comment