Answer to Question #228195 in Python for kaavya

Question #228195

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




1
Expert's answer
2021-08-24T01:54:48-0400
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)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS