![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
动态规划之背包问题
文章平均质量分 74
清溪浅水
这个作者很懒,什么都没留下…
展开
-
hdu——2602——Bone Collector 01背包问题
Problem DescriptionMany years ago , in Teddy’s hometown there was a man who was called “Bone Collector”. This man like to collect varies of bones , such as dog’s , cow’s , also he went to the grave原创 2013-08-12 20:01:31 · 499 阅读 · 0 评论 -
hdu——1114——Piggy-Bank
Problem DescriptionBefore 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原创 2014-02-13 10:45:50 · 447 阅读 · 0 评论 -
hdu——1284——钱币兑换问题
Problem Description在一个国家仅有1分,2分,3分硬币,将钱N兑换成硬币有很多种兑法。请你编程序计算出共有多少种兑法。 Input每行只有一个正整数N,N小于32768。 Output对应每个输入,输出兑换方法数。 Sample Input293412553 Sample Output7188原创 2014-02-13 10:55:19 · 635 阅读 · 0 评论 -
hdu——1059——Dividing(多重背包)
Problem DescriptionMarsha and Bill own a collection of marbles. They want to split the collection among themselves so that both receive an equal share of the marbles. This would be easy if all the m原创 2014-02-15 13:13:17 · 509 阅读 · 0 评论 -
hdu——1171——Big Event in HDU(多重背包)
Problem DescriptionNowadays, we all know that Computer College is the biggest department in HDU. But, maybe you don't know that Computer College had ever been split into Computer College and Softwar原创 2014-02-15 10:19:56 · 507 阅读 · 0 评论 -
hdu——3127——WHUgirls
Problem DescriptionThere are many pretty girls in Wuhan University, and as we know, every girl loves pretty clothes, so do they. One day some of them got a huge rectangular cloth and they want to cu原创 2014-02-13 17:33:29 · 554 阅读 · 0 评论 -
hdu——2079——选课时间(题目已修改,注意读题)
Problem Description又到了选课的时间了,xhd看着选课表发呆,为了想让下一学期好过点,他想知道学n个学分共有多少组合。你来帮帮他吧。(xhd认为一样学分的课没区别) Input输入数据的第一行是一个数据T,表示有T组数据。每组数据的第一行是两个整数n(1 接着有k行,每行有两个整数a(1 Output对于每组输入数据,输出一个原创 2014-02-15 15:53:10 · 705 阅读 · 0 评论 -
poj——2392——Space Elevator(多重)
DescriptionThe cows are going to space! They plan to achieve orbit by building a sort of space elevator: a giant tower of blocks. They have K (1 <= K <= 400) different types of blocks with which原创 2014-02-15 19:10:16 · 608 阅读 · 0 评论 -
hdu——2191——悼念512汶川大地震遇难同胞——珍惜现在,感恩生活(多重)
Problem Description急!灾区的食物依然短缺!为了挽救灾区同胞的生命,心系灾区同胞的你准备自己采购一些粮食支援灾区,现在假设你一共有资金n元,而市场有m种大米,每种大米都是袋装产品,其价格不等,并且只能整袋购买。请问:你用有限的资金最多能采购多少公斤粮食呢?后记:人生是一个充满了变数的生命过程,天灾、人祸、病痛是我们生命历程中不可预知的威胁。月有阴晴原创 2014-02-15 16:40:08 · 479 阅读 · 0 评论 -
hdu——1176——免费馅饼
Problem Description都说天上不会掉馅饼,但有一天gameboy正走在回家的小径上,忽然天上掉下大把大把的馅饼。说来gameboy的人品实在是太好了,这馅饼别处都不掉,就掉落在他身旁的10米范围内。馅饼如果掉在了地上当然就不能吃了,所以gameboy马上卸下身上的背包去接。但由于小径两侧都不能站人,所以他只能在小径上接。由于gameboy平时老呆在房间里玩游戏,虽然在游戏中是个原创 2014-02-28 12:37:13 · 523 阅读 · 0 评论 -
hdu——2159——FATE
Problem Description最近xhd正在玩一款叫做FATE的游戏,为了得到极品装备,xhd在不停的杀怪做任务。久而久之xhd开始对杀怪产生的厌恶感,但又不得不通过杀怪来升完这最后一级。现在的问题是,xhd升掉最后一级还需n的经验值,xhd还留有m的忍耐度,每杀一个怪xhd会得到相应的经验,并减掉相应的忍耐度。当忍耐度降到0或者0以下时,xhd就不会玩这游戏。xhd还说了他最多只杀s原创 2014-02-13 14:30:37 · 518 阅读 · 0 评论 -
hdu——1248——寒冰王座
Problem Description不死族的巫妖王发工资拉,死亡骑士拿到一张N元的钞票(记住,只有一张钞票),为了防止自己在战斗中频繁的死掉,他决定给自己买一些道具,于是他来到了地精商店前.死亡骑士:"我要买道具!"地精商人:"我们这里有三种道具,血瓶150块一个,魔法药200块一个,无敌药水350块一个."死亡骑士:"好的,给我一个血瓶."说原创 2014-02-13 15:05:21 · 541 阅读 · 0 评论 -
hdu——1881——毕业bg 01背包问题
Problem Description每年毕业的季节都会有大量毕业生发起狂欢,好朋友们相约吃散伙饭,网络上称为“bg”。参加不同团体的bg会有不同的感觉,我们可以用一个非负整数为每个bg定义一个“快乐度”。现给定一个bg列表,上面列出每个bg的快乐度、持续长度、bg发起人的离校时间,请你安排一系列bg的时间使得自己可以获得最大的快乐度。例如有4场bg:第1场快乐度为5,持续1小时,原创 2013-08-12 16:56:07 · 580 阅读 · 0 评论 -
hdu ——寒冰王座——完全背包问题
Problem Description不死族的巫妖王发工资拉,死亡骑士拿到一张N元的钞票(记住,只有一张钞票),为了防止自己在战斗中频繁的死掉,他决定给自己买一些道具,于是他来到了地精商店前.死亡骑士:"我要买道具!"地精商人:"我们这里有三种道具,血瓶150块一个,魔法药200块一个,无敌药水350块一个."死亡骑士:"好的,给我一个血瓶."说完他掏出那张N元的大钞递给地原创 2013-08-12 20:10:45 · 573 阅读 · 0 评论 -
背包问题解析
一.最简单的背包问题----01背包 1.题:有N件物品和一个容量为V的背包。第i件物品的体积是c[i],价值是w[i]。求解将哪些物品装入背包可使这些物品的体积总和不超过背包容量,且价值总和最大。 2.思路:每一个物品可以放也可以不放,因此比较放的时候的价值和不放的时候的价值,用max函数比较 3.方程: 即f[i][v]表示前i件物品恰放入一个容原创 2013-08-12 16:13:29 · 588 阅读 · 0 评论 -
poj——3624——Charm Bracelet
DescriptionBessie has gone to the mall's jewelry store and spies a charm bracelet. Of course, she'd like to fill it with the best charms possible from theN (1 ≤ N ≤ 3,402) available charms. Ea原创 2013-10-26 21:04:37 · 541 阅读 · 0 评论 -
hdu——2546——饭卡(0-1背包)
Problem Description电子科大本部食堂的饭卡有一种很诡异的设计,即在购买之前判断余额。如果购买一个商品之前,卡上的剩余金额大于或等于5元,就一定可以购买成功(即使购买后卡上余额为负),否则无法购买(即使金额足够)。所以大家都希望尽量使卡上的余额最少。某天,食堂中有n种菜出售,每种菜可购买一次。已知每种菜的价格以及卡上的余额,问最少可使卡上的余额为多少。 In原创 2013-10-26 19:41:57 · 601 阅读 · 0 评论 -
hdu——3466——Proud Merchants
Problem DescriptionRecently, iSea went to an ancient country. For such a long time, it was the most wealthy and powerful kingdom in the world. As a result, the people in this country are still very原创 2013-10-26 20:30:54 · 688 阅读 · 0 评论 -
poj——2063——Investment(dp)
DescriptionJohn never knew he had a grand-uncle, until he received the notary's letter. He learned that his late grand-uncle had gathered a lot of money, somewhere in South-America, and that John wa原创 2013-10-26 15:04:13 · 613 阅读 · 0 评论 -
poj——3211——Washing Clothes
DescriptionDearboy was so busy recently that now he has piles of clothes to wash. Luckily, he has a beautiful and hard-working girlfriend to help him. The clothes are in varieties of colors but ea原创 2013-11-07 11:26:03 · 770 阅读 · 0 评论 -
poj——3624——Charm Bracelet
DescriptionBessie has gone to the mall's jewelry store and spies a charm bracelet. Of course, she'd like to fill it with the best charms possible from the N (1 ≤ N ≤ 3,402) available charms. Each原创 2014-02-13 09:56:49 · 572 阅读 · 0 评论 -
hdu——2084——数塔
Problem Description在讲述DP算法的时候,一个经典的例子就是数塔问题,它是这样描述的:有如下所示的数塔,要求从顶层走到底层,若每一步只能走到相邻的结点,则经过的结点的数字之和最大是多少?已经告诉你了,这是个DP的题目,你能AC吗? Input输入数据首先包括一个整数C,表示测试实例的个数,每个测试实例的第一行是一个整数N(1 Output原创 2014-02-28 17:41:38 · 507 阅读 · 0 评论