Py||Minimum currency payment problem

题目描述
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)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值