HDOJ 2191】的更多相关文章

悼念512汶川大地震遇难同胞——珍惜现在,感恩生活 Time Limit : 1000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Problem Description 急!灾区的食物依然短缺!为了挽救灾区同胞的生命,心系灾区同胞的你准备自己采购一些粮食支援灾区,现在假设你一共有资金n元,而市场有m种大米,每种大米都是袋装产品,其价格不等,并且只能整袋购买.请问:你用有限的资金最多能采购多少公斤粮食呢? 后记:人…
多重背包. 模版. #include <iostream> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <algorithm> using namespace std; int main() { int n,m,c; ],w[],e[],dp[]; scanf("%d",&c);…
Problem Description 急!灾区的食物依然短缺! 为了挽救灾区同胞的生命,心系灾区同胞的你准备自己采购一些粮食支援灾区,现在假设你一共有资金n元,而市场有m种大米,每种大米都是袋装产品,其价格不等,并且只能整袋购买. 请问:你用有限的资金最多能采购多少公斤粮食呢? 后记: 人生是一个充满了变数的生命过程,天灾.人祸.病痛是我们生命历程中不可预知的威胁. 月有阴晴圆缺,人有旦夕祸福,未来对于我们而言是一个未知数.那么,我们要做的就应该是珍惜现在,感恩生活-- 感谢父母,他们给予我们…
Problem Description 急!灾区的食物依然短缺!为了挽救灾区同胞的生命,心系灾区同胞的你准备自己采购一些粮食支援灾区,现在假设你一共有资金n元,而市场有m种大米,每种大米都是袋装产品,其价格不等,并且只能整袋购买.请问:你用有限的资金最多能采购多少公斤粮食呢? 后记:人生是一个充满了变数的生命过程,天灾.人祸.病痛是我们生命历程中不可预知的威胁.月有阴晴圆缺,人有旦夕祸福,未来对于我们而言是一个未知数.那么,我们要做的就应该是珍惜现在,感恩生活——感谢父母,他们给予我们生命,抚养…
HDOJ(HDU).2191. 悼念512汶川大地震遇难同胞――珍惜现在,感恩生活 (DP 多重背包+二进制优化) 题意分析 首先C表示测试数据的组数,然后给出经费的金额和大米的种类.接着是每袋大米的价格,重量和袋数. 每种大米的数量是有限的,应该能看出是多重背包的问题.关键是多重背包的处理方法.对多重背包采用二进制优化的方法.设同种大米的数量为n,每袋的价格为v,那么把同一种大米分别拆成1,2,4,8,16--(直到不够2^n时,剩下的单独分成一组),拆分的价格也分别对应是v,2v,4v,8v…
多重背包. #include <stdio.h> #include <string.h> ]; int n, m; void completePac(int p, int h) { int i, tmp; for (i=p; i<=n; ++i) { tmp = dp[i-p] + h; if (dp[i] < tmp) dp[i] = tmp; } } void onezeroPac(int p, int h) { int i, tmp; for (i=n; i>…
FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 56784    Accepted Submission(s): 19009 Problem Description FatMouse prepared M pounds of cat food, ready to trade with the cats g…
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3049    Accepted Submission(s): 2364 Problem Description You are the CEO of Nasty Hacks Inc., a company that creates small pieces of…
Box of Bricks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 5994    Accepted Submission(s): 2599 Problem Description Little Bob likes playing with his box of bricks. He puts the bricks one up…
链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=2191 思路:多重背包模板题 #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <algorithm> using namespace std; int money,type; ],weigh[],num[],dp[]; i…