Hat‘s Tea(https://acs.jxnu.edu.cn/problem/HDU1288)

描述:

Hat is a member of PG Studio. Hat codes a lot and so he often buys tea at tea vending machine. But the tea vending machine just eat coins and spit out tea, if you feed the machine more coins than the tea’s price and the machine will not spit out your change.
Your program will be given numbers and types of coins Hat has and the tea price. The tea vending machine accepts coins of values 1, 5, 10 RMB (Jiao). The program should output which coins Hat has to use paying the tea so that he uses as many coins as possible.

输入:

Each line of the input contains four integer numbers separated by a single space describing one situation to solve. The first integer on the line N, , is the tea price in Jiao. Next four integers , , are the numbers of YiJiao (1 Jiao.RMB), WuJiao (5 Jiao.RMB), and ShiJiao (10 Jiao.RMB) in Hat's valet. The last line of the input contains four zeros and no output should be generated for it.

输出:

For each situation, your program should output one line containing the string " T1 YiJiao, T2 WuJiao, and T3 ShiJiao ", where T1, T2, T3 are the numbers of coins of appropriate values Hat should use to pay the tea while using as many coins as possible. If Hat does not have enough coins to pay the tea exactly, your program should output "Hat cannot buy tea.”.

输入:hat是pg工作室的一员.hat的代码很多所以他经常在自动售卖机上买茶.但是卖茶的自动售卖机上只能吞进硬币并且吐出茶,如果你投币超过了茶的售价,售货机并不会找零.你的程序需要给出硬币的数量和类型和茶价.售卖机接受数值为1,5,10角的硬币.程序应该输出茶所需要支付的硬币,以便于他能够尽可能使用多一点的硬币.

输入:每行输入4个整数(彼此空格分隔)描述需要解决的一种情况.第n行的第一个整数是茶价(以叫为单位)接下来四个是1角,5角,10角硬币的数量.输入的最后一行为四个0并且不会因此产生相应输出.

输出:对于每个情况,你的程序在一行中应该输出字符串t1yijiao,t2wujiao,t3shijiao.而t1,t2,t3是hat尽可能使用多的硬币的最合适的数字.如果hat没有足够的硬币支付.你的程序应该输出hat canot buy tea.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值