随笔分类 -  dp

吉哥系列故事――临时工计划(dp)
摘要:Time Limit:1000MSMemory Limit:32768KB64bit IO Format:%I64d & %I64uSubmitStatusDescription 俗话说一分钱难倒英雄汉,高中几年下来,吉哥已经深深明白了这个道理,因此,新年开始存储一年的个人资金已经成了习惯,不过自从大学之后他不好意思再向大人要压岁钱了,只能把唯一的希望放到自己身上。可是由于时间段的特殊性和自己能力的因素,只能找到些零零碎碎的工作,吉哥想知道怎么安排自己的假期才能获得最多的工资。 已知吉哥一共有m天的假期,每天的编号从1到m,一共有n份可以做的工作,每份工作都知道起始时间s,终止时间e和 阅读全文
posted @ 2013-11-03 21:05 straw_berry 阅读(437) 评论(0) 推荐(0)
Pearls DP
摘要:Time Limit:1000MSMemory Limit:10000KTotal Submissions:6647Accepted:3241DescriptionIn Pearlania everybody is fond of pearls. One company, called The Royal Pearl, produces a lot of jewelry with pearls in it. The Royal Pearl has its name because it delivers to the royal family of Pearlania. But it also 阅读全文
posted @ 2013-09-06 21:09 straw_berry 阅读(249) 评论(0) 推荐(0)
The Cow Lexicon(dp)
摘要:Time Limit:2000MSMemory Limit:65536KTotal Submissions:7290Accepted:3409DescriptionFew know that the cows have their own dictionary withW(1 ≤W≤ 600) words, each containing no more 25 of the characters 'a'..'z'. Their cowmunication system, based on mooing, is not very accurate; sometim 阅读全文
posted @ 2013-09-03 21:19 straw_berry 阅读(272) 评论(0) 推荐(0)
Human Gene Functions
摘要:http://poj.org/problem?id=1080题意:已知一个人类基因的积分表,给出两个字符串,计算这两个串的最大相似程度;思路:最长公共子序列的变形,用score[][] 表示积分值,dp[i][j]表示字符串s1[1,2,,,i]和s2[1,2,,,j]的分值,对一个dp[i][j],有三种可能:> s1取第i个字符,s2取‘-’时,dp[i][j] = dp[i-1][j] + score[s1[i]][0];>s1取‘-’,s2取第j个字符时,dp[i][j] = dp[i][j-1] + score[0][s2[j]];>s1取第i个字符,s2取第j个字 阅读全文
posted @ 2013-08-30 15:30 straw_berry 阅读(324) 评论(0) 推荐(0)
Palindrome(最长公共子序列)
摘要:Time Limit:3000MSMemory Limit:65536KTotal Submissions:48526Accepted:16674DescriptionA palindrome is a symmetrical string, that is, a string read identically from left to right as well as from right to left. You are to write a program which, given a string, determines the minimal number of characters 阅读全文
posted @ 2013-08-30 09:37 straw_berry 阅读(244) 评论(0) 推荐(0)
Alignment ( 最长上升(下降)子序列 )
摘要:Time Limit:1000MSMemory Limit:30000KTotal Submissions:11397Accepted:3630DescriptionIn the army, a platoon is composed by n soldiers. During the morning inspection, the soldiers are aligned in a straight line in front of the captain. The captain is not satisfied with the way his soldiers are aligned; 阅读全文
posted @ 2013-08-28 16:22 straw_berry 阅读(265) 评论(0) 推荐(0)
Balance(01背包)
摘要:Time Limit:1000MSMemory Limit:30000KTotal Submissions:9163Accepted:5617DescriptionGigel 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 ar 阅读全文
posted @ 2013-08-23 21:22 straw_berry 阅读(222) 评论(0) 推荐(0)
Cash Machine(多重背包)
摘要:Time Limit:1000MSMemory Limit:10000KTotal Submissions:24067Accepted:8414DescriptionA 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 denominations, say Dk, k=1,N, and for eac 阅读全文
posted @ 2013-08-23 12:48 straw_berry 阅读(330) 评论(0) 推荐(0)
跳格子 完全背包
摘要:sdut 2594毛线除了泡妹子以外最喜欢的就是玩些无聊的游戏了。他最近又迷上了一个非常无聊的游戏,那就是...跳格子。他在墙边画了许许多多的格子,每次从外面往墙的那边跳,使自己更加靠近墙。为了增加下游戏的难度,毛线每次跳之前会规定下自己每次能跳几个格子,然后试着让自己在这个限制下最靠近墙。输入输入包含多组数据,对于每组测试数据:第一个给出格子的总数 N(1 2 #include 3 int c[20],dp[1000010]; 4 int main () 5 { 6 int n,m; 7 while(~scanf("%d %d",&n,&m... 阅读全文
posted @ 2013-05-11 20:48 straw_berry 阅读(176) 评论(0) 推荐(0)
Bone Collector 01背包
摘要:Many 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 …The bone collector had a big bag with a volume of V ,and along his trip of collecting there are a lot of bones , obvious 阅读全文
posted @ 2013-05-02 18:01 straw_berry 阅读(166) 评论(0) 推荐(0)
免费馅饼
摘要:题目描述都说天上不会掉馅饼,但有一天gameboy正走在回家的小径上,忽然天上掉下大把大把的馅饼。说来gameboy的人品实在是太好了,这馅饼别处都不掉,就掉落在他身旁的10米范围内。馅饼如果掉在了地上当然就不能吃了,所以gameboy马上卸下身上的背包去接。但由于小径两侧都不能站人,所以他只能在小径上接。由于gameboy平时老呆在房间里玩游戏,虽然在游戏中是个身手敏捷的高手,但在现实中运动神经特别迟钝,每秒种只有在移动不超过一米的范围内接住坠落的馅饼。现在给这条小径如图标上坐标: 为了使问题简化,假设在接下来的一段时间里,馅饼都掉落在0-10这11个位置。开始时gameboy站在5这个位置 阅读全文
posted @ 2013-04-25 15:53 straw_berry 阅读(131) 评论(0) 推荐(0)
最长公共子序列
摘要:给定两个序列X=输入输入数据有多组,每组有两行 ,每行为一个长度不超过500的字符串(输入全是大写英文字母(A,Z)),表示序列X和Y。输出每组输出一行,表示所求得的最长公共子序列的长度,若不存在公共子序列,则输出0。示例输入ABCBDABBDCABA示例输出4 1 #include 2 #include 3 int main () 4 { 5 char s1[510], s2[510]; 6 int i,j,maxsum[510][510]; 7 while(gets(s1)) 8 { 9 ... 阅读全文
posted @ 2013-04-23 20:58 straw_berry 阅读(172) 评论(0) 推荐(0)