Py||Minimum currency payment problem

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/Lhw_666/article/details/102738921

题目描述
The current monetary system is (1, 2, 5, 10, 20, 50, 100).

Please design an algorithm that given a number A, calculate the amount of each currency required to pay with the minimum number of currencies.
输入
The first line is the number of test cases n, n≤1000.

For the next n lines, each line is a test case, and each test case is an integer m, 0≤m≤10000.
输出
For each test case, output a line of 7 integers separated by Spaces, representing the number used by 1 yuan, 2 yuan, 5 yuan, 10 yuan, 20 yuan, 50 yuan and 100 yuan respectively.
样例输入 Copy
2
15
189
样例输出 Copy
0 0 1 1 0 0 0
0 2 1 1 1 1 1

n=int(input())
for i in range(n):
    a=int(input())
    b=a//100
    b1=a%100
    c=b1//50
    c1=b1%50
    d=c1//20
    d1=c1%20
    e=d1//10
    e1=d1%10
    f=e1//5
    f1=e1%5
    g=f1//2
    g1=f1%2
    h=g1//1
    h1=g1%1
    print(h,g,f,e,d,c,b)

猜你喜欢

转载自blog.csdn.net/Lhw_666/article/details/102738921