随笔分类 -  DP

上一页 1 2 3 下一页
POJ 1463 Strategic game【树形DP】
摘要:DescriptionBob enjoys playing computer games, especially strategic games, but sometimes he cannot find the solution fast enough and then he is very sad. Now he has the following problem. He must defend a medieval city, the roads of which form a tree. He has to put the minimum number of soldiers on t 阅读全文
posted @ 2012-07-31 18:33 crying_Dream 阅读(187) 评论(0) 推荐(0)
HDU 1520 Anniversary party【树形DP】
摘要:Problem DescriptionThere is going to be a party to celebrate the 80-th Anniversary of the Ural State University. The University has a hierarchical structure of employees. It means that the supervisor relation forms a tree rooted at the rector V. E. Tretyakov. In order to make the party funny for eve 阅读全文
posted @ 2012-07-31 18:31 crying_Dream 阅读(162) 评论(0) 推荐(0)
POJ 1050 To the Max【最大子矩阵】
摘要:DescriptionGiven a two-dimensional array of positive and negative integers, a sub-rectangle is any contiguous sub-array of size 1*1 or greater located within the whole array. The sum of a rectangle is the sum of all the elements in that rectangle. In this problem the sub-rectangle with the largest s 阅读全文
posted @ 2012-07-31 18:28 crying_Dream 阅读(153) 评论(0) 推荐(0)
HDU 1003 Max Sum【最大连续子序列的和】
摘要:Problem DescriptionGiven a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the max sum in this sequence is 6 + (-1) + 5 + 4 = 14.InputThe first line of the input contains an integer T(1<=T<=20) which means the number 阅读全文
posted @ 2012-07-31 18:26 crying_Dream 阅读(213) 评论(0) 推荐(0)
HDU 1505 City Game【矩阵的最大面积】
摘要:Problem DescriptionBob is a strategy game programming specialist. In his new city building game the gaming environment is as follows: a city is built up by areas, in which there are streets, trees,factories and buildings. There is still some space in the area that is unoccupied. The strategic task o 阅读全文
posted @ 2012-07-31 15:49 crying_Dream 阅读(240) 评论(0) 推荐(0)
HDU 1506 Largest Rectangle in a Histogram【矩阵最大面积】
摘要:Problem DescriptionA histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have equal widths but may have different heights. For example, the figure on the left shows the histogram that consists of rectangles with the heights 2, 1, 4, 5, 1, 3, 3, m 阅读全文
posted @ 2012-07-31 15:47 crying_Dream 阅读(279) 评论(0) 推荐(0)
HDU 3496 Watch The Movie【二维背包】
摘要:Problem DescriptionNew semester is coming, and DuoDuo has to go to school tomorrow. She decides to have fun tonight and will be very busy after tonight. She like watch cartoon very much. So she wants her uncle to buy some movies and watch with her tonight. Her grandfather gave them L minutes to watc 阅读全文
posted @ 2012-07-31 15:43 crying_Dream 阅读(236) 评论(0) 推荐(0)
HDU 2159 FATE【二维费用背包】
摘要:Problem Description最近xhd正在玩一款叫做FATE的游戏,为了得到极品装备,xhd在不停的杀怪做任务。久而久之xhd开始对杀怪产生的厌恶感,但又不得不通过杀怪来升完这最后一级。现在的问题是,xhd升掉最后一级还需n的经验值,xhd还留有m的忍耐度,每杀一个怪xhd会得到相应的经验,并减掉相应的忍耐度。当忍耐度降到0或者0以下时,xhd就不会玩这游戏。xhd还说了他最多只杀s只怪。请问他能升掉这最后一级吗?Input输入数据有多组,对于每组数据第一行输入n,m,k,s(0 < n,m,k,s < 100)四个正整数。分别表示还需的经验值,保留的忍耐度,怪的种数和最 阅读全文
posted @ 2012-07-31 15:39 crying_Dream 阅读(197) 评论(0) 推荐(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 marbles had the same value, because then they could just split the collection in half. But unfortunatel 阅读全文
posted @ 2012-07-31 15:34 crying_Dream 阅读(194) 评论(0) 推荐(0)
HDU 2191 悼念512汶川大地震遇难同胞——珍惜现在,感恩生活【多重背包】
摘要:Problem Description急!灾区的食物依然短缺!为了挽救灾区同胞的生命,心系灾区同胞的你准备自己采购一些粮食支援灾区,现在假设你一共有资金n元,而市场有m种大米,每种大米都是袋装产品,其价格不等,并且只能整袋购买。请问:你用有限的资金最多能采购多少公斤粮食呢?后记:人生是一个充满了变数的生命过程,天灾、人祸、病痛是我们生命历程中不可预知的威胁。月有阴晴圆缺,人有旦夕祸福,未来对于我们而言是一个未知数。那么,我们要做的就应该是珍惜现在,感恩生活——感谢父母,他们给予我们生命,抚养我们成人;感谢老师,他们授给我们知识,教我们做人感谢朋友,他们让我们感受到世界的温暖;感谢对手,他们令我 阅读全文
posted @ 2012-07-31 15:26 crying_Dream 阅读(172) 评论(0) 推荐(0)
POJ 2063 Investment【完全背包】
摘要: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 was the only inheritor. John did not need that much money for the moment. But he realized that it wo 阅读全文
posted @ 2012-07-31 15:23 crying_Dream 阅读(196) 评论(0) 推荐(0)
POJ 3624 Charm Bracelet【01背包】
摘要: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 charm i in the supplied list has a weight Wi (1 ≤ Wi ≤ 400), a 'desirability' factor Di 阅读全文
posted @ 2012-07-31 15:16 crying_Dream 阅读(155) 评论(0) 推荐(0)
POJ 1837 Balance【DP】
摘要:DescriptionGigel has a strange "balance" and he wants to poise it. Actually, the device is different from any other ordinary balance.It orders two arms of negligible weight and each arm's length is 15. Some hooks are attached to these arms and Gigel wants to hang up some weights from h 阅读全文
posted @ 2012-07-31 15:08 crying_Dream 阅读(193) 评论(0) 推荐(0)
HRBUST 1478 最长公共子序列的最小字典序
摘要:Description给定两个字符串,输出他们的最长公共子序列,要求字典序最小。Input有多组数据,每组数据包含两行,每行一个字符串,每个字符串的长度不超过1000。每个字符串仅包含小写字母。Output对于每组数据,输出一行,字典序最小的公共子序列。Sample InputabcdefghaaaabcdefghbbboxuhiehozuoxuhijednrehozujudgzSample Outputabcdefghououjd思路:和上一道题很像,但是再求最长公共子序列的时候应该倒着求,从最小字符'a'枚举但是在枚举时是从最后一个开始的所以就逆序过来操作。代码如下:#in 阅读全文
posted @ 2012-07-31 15:04 crying_Dream 阅读(804) 评论(1) 推荐(0)
POJ 1934 Trip【最长公共子序列输出】
摘要:DescriptionAlice and Bob want to go on holiday. Each of them has planned a route, which is a list of cities to be visited in a given order. A route may contain a city more than once.As they want to travel together, they have to agree on a common route. None wants to change the order of the cities on 阅读全文
posted @ 2012-07-31 15:00 crying_Dream 阅读(605) 评论(0) 推荐(0)
HRBUST 1220 过河【DP+状态】
摘要:Description在河上有一座独木桥,一只青蛙想沿着独木桥从河的一侧跳到另一侧。在桥上有一些石子,青蛙很讨厌踩在这些石子上。由于桥的长度和青蛙一次跳过的距离都是正整数,我们可以把独木桥上青蛙可能到达的点看成数轴上的一串整点:0,1,……,L(其中L是桥的长度)。坐标为0的点表示桥的起点,坐标为L的点表示桥的终点。青蛙从桥的起点开始,不停的向终点方向跳跃。一次跳跃的距离是S到T之间的任意正整数(包括S,T)。当青蛙跳到或跳过坐标为L的点时,就算青蛙已经跳出了独木桥。题目给出独木桥的长度L,青蛙跳跃的距离范围S,T,桥上石子的位置。你的任务是确定青蛙要想过河,最少需要踩到的石子数。Input有 阅读全文
posted @ 2012-07-31 14:50 crying_Dream 阅读(305) 评论(0) 推荐(0)
HRBUST 1476 教主们毕业设计排版==算法导论上的思考题整齐打印
摘要:Description大四的教主们毕业了。虽然是教主,但是毕业前都得拿出毕业设计才能得到学士学位,正式毕业。毕业设计文档的排版有严格要求,排版上不能有一点错误,哪怕已经打印了,也要再修改文档重新打印,所以文档必须排版良好,整齐美观。然后就有了如下求“整齐度”的简化的题目:假设正文是n个长度分别为L1、L2、……、Ln(以字符个数度量,不计空白子字符)的单词构成的序列。我们希望将这个段落在一些行上整齐地打印出来,每行至多M个字符。“整齐度”的标准如下:如果某一行包含从i到j的单词(i<j),且单词之间只留一个空格,则在行末多余的空格字符个数为 M - (j-i) - (Li+ …… + L 阅读全文
posted @ 2012-07-31 14:44 crying_Dream 阅读(951) 评论(0) 推荐(0)
POJ 1745 Divisibility【DP】
摘要:Language:DivisibilityTime Limit:1000MSMemory Limit:10000KTotal Submissions:8396Accepted:2909DescriptionConsider an arbitrary sequence of integers. One can place + or - operators between integers in the sequence, thus deriving different arithmetical expressions that evaluate to different values. Let 阅读全文
posted @ 2012-07-31 14:40 crying_Dream 阅读(302) 评论(0) 推荐(0)
HDU 1011 Starship Troopers【DP】
摘要:Problem DescriptionYou, the leader of Starship Troopers, are sent to destroy a base of the bugs. The base is built underground. It is actually a huge cavern, which consists of many rooms connected with tunnels. Each room is occupied by some bugs, and their brains hide in some of the rooms. Scientist 阅读全文
posted @ 2012-07-31 14:36 crying_Dream 阅读(261) 评论(0) 推荐(0)
HRBUST 1162 魔女【DP】
摘要:Description 平行世界是动漫作品中经常涉及的题材,而且往往这些作品都相当的精彩,如《寒蝉鸣泣之时》、《CLANNAD》、《魔法少女小圆》、《命运石之门》等。世界从诞生到结束,最终又轮回到诞生。无论命运如何的绝对,在无数次的轮回中终将被打破,犹如掷骰子,在无限接近于零但不等于零的机率中往复。这样在无限的反复和轮回中,将其可能性放大到100%。最典型的人物就是《海猫鸣泣之时》中的能无限次引发奇迹力量的“奇迹之魔女”贝伦卡斯泰露。而与此对应的是能够让事件发生的可能性无限接近于零“绝对的魔女”拉姆达戴露塔。在故事中,贝伦的目的是为了令主角战人在黄金魔女的游戏中“赢”,而拉姆达的目的则是为了让 阅读全文
posted @ 2012-07-31 14:26 crying_Dream 阅读(269) 评论(0) 推荐(0)

上一页 1 2 3 下一页