HDU-1114 Piggy-Bank 完全背包的灵活运用

ACM在准备预算时需要使用Irreversibly Bound Money(IBM),通过收集硬币存入储蓄罐。由于无法确定储蓄罐内的金额,只能通过称重估算。题目要求根据储蓄罐的重量和硬币的重量及面值,找到储蓄罐内可能的最低金额。输入包含测试用例数量、空罐和满罐重量、硬币种类及每种硬币的面值和重量。输出是最小金额或“不可能”。本题是寻找最小值的完全背包问题,需要初始化DP数组为最大值,且DP[0]为0。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Piggy-Bank

Before ACM can do anything, a budget must be prepared and the necessary financial support obtained. The main income for this action comes from Irreversibly Bound Money (IBM). The idea behind is simple. Whenever some ACM member has any small money, he takes all the coins and throws them into a piggy-bank. You know that this process is irreversible, the coins cannot be removed without breaking the pig. After a sufficiently long time, there should be enough cash in the piggy-bank to pay everything that needs to be paid.

But there is a big problem with piggy-banks. It is not possible to determine how much money is inside. So we might break the pig into pieces only to find out that there is not enough money. Clearly, we want to avoid this unpleasant situation. The only possibility is to weigh the piggy-bank and try to guess how many coins are inside. Assume that we are able to determine the weight of the pig exactly and that we know the weight

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值