HDU1114 完全背包变形
来源:互联网 发布:方正字库官网 mac 编辑:程序博客网 时间:2024/05/15 03:46
Piggy-Bank
Time Limit: 2000/1000 MS(Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 1902 Accepted Submission(s): 961
Problem Description
Before ACM can do anything, a budget must be prepared andthe necessary financial support obtained. The main income for this action comesfrom Irreversibly Bound Money (IBM). The idea behind is simple. Whenever someACM member has any small money, he takes all the coins and throws them into apiggy-bank. You know that this process is irreversible, the coins cannot beremoved without breaking the pig. After a sufficiently long time, there shouldbe 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 determinehow much money is inside. So we might break the pig into pieces only to findout that there is not enough money. Clearly, we want to avoid this unpleasantsituation. The only possibility is to weigh the piggy-bank and try to guess howmany coins are inside. Assume that we are able to determine the weight of thepig exactly and that we know the weights of all coins of a given currency. Thenthere is some minimum amount of money in the piggy-bank that we can guarantee.Your task is to find out this worst case and determine the minimum amount ofcash inside the piggy-bank. We need your help. No more prematurely broken pigs!
Input
The input consists of T test cases. The number of them(T) is given on the first line of the input file. Each test case begins with aline containing two integers E and F. They indicate the weight of an empty pigand of the pig filled with coins. Both weights are given in grams. No pig willweigh more than 10 kg, thatmeans 1 <= E <= F <= 10000. On the second line of each test case,there is an integer number N (1 <= N <= 500) that gives the number ofvarious coins used in the given currency. Following this are exactly N lines,each specifying one coin type. These lines contain two integers each, Pand W (1<= P <= 50000, 1 <= W <=10000). P is the value of the coin inmonetary units, W is it's weight in grams.
Output
Print exactly one line of output for each test case. Theline must contain the sentence "The minimum amount of money in thepiggy-bank is X." where X is the minimum amount of money that can beachieved using coins with the given total weight. If the weight cannot bereached exactly, print a line "This is impossible.".
Sample Input
3
10 110
2
1 1
30 50
10 110
2
1 1
50 30
1 6
2
10 3
20 4
Sample Output
The minimum amount of money in the piggy-bank is 60.
The minimum amount of money in the piggy-bank is 100.
This is impossible.
完全背包的变形,改成背包问题的描述就是,求出把背包装满可以获得的最小的价值.
- HDU1114 完全背包变形
- hdu1114(完全背包变形)
- HDU1114 Piggy-Bank完全背包变形
- hdu1114 & poj1384 完全背包
- hdu1114完全背包
- HDU1114完全背包
- hdu1114(完全背包)
- hdu1114完全背包
- hdu1114(完全背包)
- HDU1114(完全背包)
- hdu1114 完全背包
- hdu1114 完全背包
- HDU1114完全背包模板
- hdu1114 Piggy-Bank 完全背包
- Piggy-Bank hdu1114 完全背包
- hdu1114 Piggy-Bank (完全背包)
- HDU1114(完全背包问题)
- 简单的完全背包HDU1114
- IE事件模型中的fireEvent
- WINCE应用程序和驱动间通信
- memset用法详解[转]
- 详细解析Linux目录结构
- C++中的单例模式
- HDU1114 完全背包变形
- vs2008切换cs文件快捷键
- 高清DV 菲星数码摄像机HDV-D503FS 专业解读
- Ubuntu 10.04 更新源(ubuntu yuan)
- 设计模式之单例模式
- 一些常用的Linux命令
- Visual Studio 2008转Visual Studio 2010的模板问题
- 饿汉式与懒汉式
- Ext 事件处理机制