DP
文章平均质量分 79
amateur
这个作者很懒,什么都没留下…
展开
-
hdu 1117 免费馅饼
Problem Description都说天上不会掉馅饼,但有一天gameboy正走在回家的小径上,忽然天上掉下大把大把的馅饼。说来gameboy的人品实在是太好了,这馅饼别处都不掉,就掉落在他身旁的10米范围内。馅饼如果掉在了地上当然就不能吃了,所以gameboy马上卸下身上的背包去接。但由于小径两侧都不能站人,所以他只能在小径上接。由于gameboy平时老呆在房间里玩游戏,虽然在游戏中是个原创 2012-08-12 12:11:07 · 993 阅读 · 0 评论 -
poj 3486
题目: http://poj.org/problem?id=3486 题解: dp[i]为前i年都有电脑用的最小花费,那么dp[i]=min(dp[j-1]+c+a[j][i]),即前j-1年有电脑用的最小花费加上买第j年电脑一直用到第i年的花费中取一个最小值。 代码: #include #include const int N=1005; int dp[N],a[原创 2012-11-18 16:26:52 · 568 阅读 · 0 评论 -
poj 1141(Brackets Sequence)
题目:http://acm.pku.edu.cn/JudgeOnline/problem?id=1141 黑书上DP第一道题,但这题要考虑输出。书上分了四种情况考虑,但我觉得只要考虑两种就行了(分为两个合法串和不分,然后设一个标志数组pre记录分开的位置),这样输出更方便。第一种情况s[i]='('&&s[j]=')' 或者s[i]='['&&s[j]=']',则d[i][j原创 2012-11-17 19:30:55 · 1240 阅读 · 1 评论 -
poj 1322 Chocolate
题目:http://poj.org/problem?id=1322 题意:有C种不同颜色的巧克力,每种巧克力同样多,把巧克力一个一个拿到桌子上,当发现有相同颜色就把相同颜色的吃掉,求取出n个后,还剩m个在桌子上的概率。 刚开始被题目的数据范围吓住了,知道用dp,但不敢下手,看了discuss,尼玛把大于1000的奇数改为1001,偶数改为1000就行了,不知道为什么是对的,试着敲了下原创 2012-12-01 21:53:08 · 874 阅读 · 0 评论 -
hdu 1561 The more, The Better (树形DP)
Problem DescriptionACboy很喜欢玩一种战略游戏,在一个地图上,有N座城堡,每座城堡都有一定的宝物,在每次游戏中ACboy允许攻克M个城堡并获得里面的宝物。但由于地理位置原因,有些城堡不能直接攻克,要攻克这些城堡必须先攻克其他某一个特定的城堡。你能帮ACboy算出要获得尽量多的宝物应该攻克哪M个城堡吗?Input每个测试实例首先包括2个整数,N,M.(1 = 0。当原创 2012-09-13 19:40:12 · 1121 阅读 · 0 评论 -
hdu 2845 Beans
Problem DescriptionBean-eating is an interesting game, everyone owns an M*N matrix, which is filled with different qualities beans. Meantime, there is only one bean in any 1*1 grid. Now you want to原创 2012-08-18 00:53:55 · 434 阅读 · 0 评论 -
hdu 1257 最少拦截系统
Problem Description某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的高度.某天,雷达捕捉到敌国的导弹来袭.由于该系统还在试用阶段,所以只有一套系统,因此有可能不能拦截所有的导弹.怎么办呢?多搞几套系统呗!你说说倒蛮容易,成本呢?成本是个大问题啊.所以俺就到这里来求原创 2012-08-17 15:48:25 · 372 阅读 · 0 评论 -
HDU 1684 最大报销额
Problem Description现有一笔经费可以报销一定额度的发票。允许报销的发票类型包括买图书(A类)、文具(B类)、差旅(C类),要求每张发票的总额不得超过1000元,每张发票上,单项物品的价值不得超过600元。现请你编写程序,在给出的一堆发票中找出可以报销的、不超过给定额度的最大报销额。 Input测试输入包含若干测试用例。每个测试用例的第1行包含两个正数原创 2012-08-17 01:40:57 · 570 阅读 · 0 评论 -
poj 1276 Cash Machine (多重背包)
DescriptionA Bank plans to install a machine for cash withdrawal. The machine is able to deliver appropriate @ bills for a requested cash amount. The machine uses exactly N distinct bill denominatio原创 2012-08-14 15:54:13 · 356 阅读 · 0 评论 -
hdu 2639 Bone Collector II(第K优背包)
Problem DescriptionThe title of this problem is familiar,isn't it?yeah,if you had took part in the "Rookie Cup" competition,you must have seem this title.If you haven't seen it before,it doesn't m原创 2012-08-13 17:52:15 · 1853 阅读 · 0 评论 -
hdu 1078 FatMouse and Cheese (搜索+dp)
Problem DescriptionFatMouse has stored some cheese in a city. The city can be considered as a square grid of dimension n: each grid location is labelled (p,q) where 0 <= p < n and 0 <= q < n. At eac原创 2012-08-13 11:11:06 · 386 阅读 · 0 评论 -
hdu Free DIY Tour (旅行商问题)
Problem DescriptionWeiwei is a software engineer of ShiningSoft. He has just excellently fulfilled a software project with his fellow workers. His boss is so satisfied with their job that he decide原创 2012-08-13 10:57:47 · 673 阅读 · 0 评论 -
hdu 1978 How many ways
Problem Description这是一个简单的生存游戏,你控制一个机器人从一个棋盘的起始点(1,1)走到棋盘的终点(n,m)。游戏的规则描述如下:1.机器人一开始在棋盘的起始点并有起始点所标有的能量。2.机器人只能向右或者向下走,并且每走一步消耗一单位能量。3.机器人不能在原地停留。4.当机器人选择了一条可行路径后,当他走到这条路径的终点时,他将只有终点所标记的能量。原创 2012-08-13 10:46:58 · 316 阅读 · 0 评论 -
poj 1384 Piggy-Bank (完全背包)
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 idea beh原创 2012-08-13 15:46:04 · 492 阅读 · 0 评论 -
hdu 1712 ACboy needs your help (分组背包)
Problem DescriptionACboy has N courses this term, and he plans to spend at most M days on study.Of course,the profit he will gain from different course depending on the days he spend on it.How to ar原创 2012-08-13 12:56:17 · 539 阅读 · 0 评论 -
hdu 1058 Humble Numbers (DP)
Problem DescriptionA number whose only prime factors are 2,3,5 or 7 is called a humble number. The sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27, ... shows the first原创 2012-08-13 10:33:12 · 432 阅读 · 0 评论 -
hdu 1421 搬寝室 (DP)
Problem Description搬寝室是很累的,xhd深有体会.时间追述2006年7月9号,那天xhd迫于无奈要从27号楼搬到3号楼,因为10号要封楼了.看着寝室里的n件物品,xhd开始发呆,因为n是一个小于2000的整数,实在是太多了,于是xhd决定随便搬2*k件过去就行了.但还是会很累,因为2*k也不小是一个不大于n的整数.幸运的是xhd根据多年的搬东西的经验发现每搬一次的疲劳度是和原创 2012-08-13 10:09:59 · 354 阅读 · 0 评论 -
hdu 2577 How to Type(DP)
Problem DescriptionPirates have finished developing the typing software. He called Cathy to test his typing software. She is good at thinking. After testing for several days, she finds that if she typ原创 2012-08-13 09:47:14 · 347 阅读 · 0 评论 -
poj 2738 Two Ends
题目:http://poj.org/problem?id=2738 没什么好说的,记忆化搜索··· #include #include #include using namespace std; int a[1005]; int dp[1005][1005]; int max(int i,int j) { return i>j?i:j; }原创 2012-11-18 16:52:47 · 561 阅读 · 0 评论