
dp-简单dp
文章平均质量分 83
2997ms
这个作者很懒,什么都没留下…
展开
-
hihocoder 1290:Demo Day
#1290 : Demo Day时间限制:10000ms单点时限:1000ms内存限制:256MB描述You work as an intern at a robotics startup. Today is your company's demo day. During the demo your company's robot wil原创 2016-04-10 21:51:10 · 790 阅读 · 0 评论 -
51nod 1084:矩阵取数问题 V2
1084 矩阵取数问题 V2基准时间限制:2 秒 空间限制:131072 KB 分值: 80 难度:5级算法题 收藏 关注一个M*N矩阵中有不同的正整数,经过这个格子,就能获得相应价值的奖励,先从左上走到右下,再从右下走到左上。第1遍时只能向下和向右走,第2遍时只能向上和向左走。两次如果经过同一个格子,则该格子的奖励只计算一次,求能够获得原创 2015-12-19 15:19:58 · 1285 阅读 · 0 评论 -
51nod 1202:子序列个数
1202 子序列个数题目来源: 福州大学 OJ基准时间限制:1 秒 空间限制:131072 KB 分值: 40 难度:4级算法题 收藏 取消关注子序列的定义:对于一个序列a=a[1],a[2],......a[n]。则非空序列a'=a[p1],a[p2]......a[pm]为a的一个子序列,其中1例如4,14,2,3和14,原创 2015-12-19 15:09:59 · 1195 阅读 · 0 评论 -
Week of Code:GG
题意是给出一个数n,一个长度为n-1的字符串。求的是1到n符合要求的序列的数量,该序列需要满足当该位置为G时,这个位置的数大于后面位置的数。当该位置为L时,这个位置的数要小于后面位置的数。最后数量模m。dp[x][y]表示x个数,以x数里面第y小的数结尾的符合要求的数量。然后如果该位置为G,也就是说新来的数比原来结尾的数要小(注意等于也可以),那么dp[i+1][k]=sum(dp[i][原创 2015-11-30 22:47:55 · 510 阅读 · 0 评论 -
HDU 5564:Clarke and digits 收获颇多的矩阵快速幂 + 前缀和
Clarke and digits Accepts: 16 Submissions: 29 Time Limit: 5000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)问题描述克拉克是一名人格分裂患者。某一天,克拉克变成了一个研究人员,在研究数字。 他想原创 2015-11-19 23:40:36 · 1027 阅读 · 0 评论 -
Hackerrank :Candies
CandiesProblem StatementAlice is a kindergarden teacher. She wants to give some candies to the children in her class. All the children sit in a line ( their positions are fixed), and ea原创 2015-12-10 20:31:54 · 1451 阅读 · 0 评论 -
51nod 1179:最大的最大公约数
1179 最大的最大公约数题目来源: SGU基准时间限制:1 秒 空间限制:131072 KB 分值: 40 难度:4级算法题 收藏 关注给出N个正整数,找出N个数两两之间最大公约数的最大值。例如:N = 4,4个数为:9 15 25 16,两两之间最大公约数的最大值是15同25的最大公约数5。Inpu原创 2015-10-13 20:46:40 · 663 阅读 · 0 评论 -
POJ 3267:The Cow Lexicon 字符串匹配dp
The Cow LexiconTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 8905 Accepted: 4228DescriptionFew know that the cows have their own dictionary with W (原创 2015-10-28 18:50:00 · 615 阅读 · 0 评论 -
HDU 1003:Max Sum
Max SumTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 174588 Accepted Submission(s): 40639Problem DescriptionGiven a sequenc原创 2015-07-13 10:18:33 · 482 阅读 · 0 评论 -
51nod 1154:回文串划分
1154 回文串划分基准时间限制:1 秒 空间限制:131072 KB 分值: 40 难度:4级算法题 收藏 关注有一个字符串S,求S最少可以被划分为多少个回文串。例如:abbaabaa,有多种划分方式。a|bb|aabaa - 3 个回文串a|bb|a|aba|a - 5 个回文串a|b|b|a|a|b|a|原创 2015-12-20 14:48:49 · 1483 阅读 · 0 评论 -
51nod 1270:数组的最大代价
1270 数组的最大代价题目来源: HackerRank基准时间限制:1 秒 空间限制:131072 KB 分值: 20 难度:3级算法题 收藏 关注数组A包含N个元素A1, A2......AN。数组B包含N个元素B1, B2......BN。并且数组A中的每一个元素Ai,都满足1 (公式表示所有两个相邻元素原创 2015-12-04 11:06:27 · 679 阅读 · 0 评论 -
51nod 1201:整数划分 超级好的DP题目
1201 整数划分基准时间限制:1 秒 空间限制:131072 KB 分值: 80 难度:5级算法题 收藏 关注将N分为若干个不同整数的和,有多少种不同的划分方式,例如:n = 6,{6} {1,5} {2,4} {1,2,3},共4种。由于数据较大,输出Mod 10^9 + 7的结果即可。Input输入1原创 2015-09-26 18:22:34 · 1943 阅读 · 0 评论 -
Codeforces 623B:Array GCD
B. Array GCDtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given array ai of length n. You may原创 2016-02-23 19:49:10 · 1291 阅读 · 1 评论 -
HDU 5617:Jam's maze 又被DP教育了
Jam's maze Accepts: 59 Submissions: 215 Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)问题描述Jam走进了一个迷宫,他要想走出这个迷宫,必须找到一条路径,使得这条路径是回文的当然他可不屑原创 2016-02-02 18:23:59 · 618 阅读 · 0 评论 -
51nod 1020:逆序排列 DP
1020 逆序排列基准时间限制:2 秒 空间限制:131072 KB 分值: 80 难度:5级算法题 收藏 关注在一个排列中,如果一对数的前后位置与大小顺序相反,即前面的数大于后面的数,那么它们就称为一个逆序。一个排列中逆序的总数就称为这个排列的逆序数。如2 4 3 1中,2 1,4 3,4 1,3 1是逆序,逆序数是4。原创 2016-02-11 13:27:31 · 1087 阅读 · 0 评论 -
Codeforces 607A:Chain Reaction 二分+递推
A. Chain Reactiontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n beacons located at distinct p原创 2015-12-24 22:30:07 · 991 阅读 · 0 评论 -
Codeforces 615C:Longtail Hedgehog
B. Longtail Hedgehogtime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis Christmas Santa gave Masha a magi原创 2016-01-09 20:53:43 · 553 阅读 · 0 评论 -
51nod 1455:宝石猎人
1455 宝石猎人题目来源: CodeForces基准时间限制:2 秒 空间限制:131072 KB 分值: 40 难度:4级算法题 收藏 关注苏塞克岛是一个有着30001个小岛的群岛,这些小岛沿着一条直线均匀间隔分布,从西到东编号为0到30000。众所周知,这些岛上有很多宝石,在苏塞克岛上总共有n颗宝石,并且第i颗宝石位于岛原创 2015-12-24 08:44:42 · 865 阅读 · 0 评论 -
POJ 2229:Sumsets
SumsetsTime Limit: 2000MS Memory Limit: 200000KTotal Submissions: 14930 Accepted: 5965DescriptionFarmer John commanded his cows to search for different sets of原创 2015-12-04 23:57:26 · 345 阅读 · 0 评论 -
HDU 5280 BestCoder Round #47 1001:Senior's Array
Senior's Array Accepts: 199 Submissions: 944 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)问题描述某天学姐姐得到了一个数组A,在这个数组的所有非空区间中,她找出了一个区间和最大的,并原创 2015-07-11 21:27:02 · 651 阅读 · 0 评论 -
HDU 5464:Clarke and problem
Clarke and problem Accepts: 130 Submissions: 781 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)问题描述克拉克是一名人格分裂患者。某一天,克拉克分裂成了一个学生,在做题。 突然一原创 2015-09-20 10:56:05 · 597 阅读 · 0 评论 -
POJ 1745:Divisibility 枚举某一状态的DP
DivisibilityTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 11001 Accepted: 3933DescriptionConsider an arbitrary sequence of integers. One can place +原创 2015-08-04 22:47:46 · 651 阅读 · 0 评论 -
POJ 1160:Post Office 邮局经典DP
Post OfficeTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 17168 Accepted: 9270DescriptionThere is a straight highway with villages alongside the high原创 2015-08-04 22:28:15 · 2446 阅读 · 1 评论 -
POJ 1887:Testing the CATCHER 求递减序列的最大值
Testing the CATCHERTime Limit: 1000MS Memory Limit: 30000KTotal Submissions: 16131 Accepted: 5924DescriptionA military contractor for the Department of Defense原创 2015-08-11 10:12:38 · 453 阅读 · 0 评论 -
POJ 1836:Alignment
AlignmentTime Limit: 1000MS Memory Limit: 30000KTotal Submissions: 14492 Accepted: 4698DescriptionIn the army, a platoon is composed by n soldiers. During the m原创 2015-08-11 10:10:23 · 413 阅读 · 0 评论 -
POJ 1260:Pearls 珍珠DP
PearlsTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 7947 Accepted: 3949DescriptionIn Pearlania everybody is fond of pearls. One company, called The原创 2015-08-11 09:31:40 · 516 阅读 · 0 评论 -
POJ 1651:Multiplication Puzzle 矩阵相乘式DP
Multiplication PuzzleTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 7118 Accepted: 4385DescriptionThe multiplication puzzle is played with a row of c原创 2015-08-10 10:53:55 · 133 阅读 · 0 评论 -
POJ 1080:Human Gene Functions LCS经典DP
Human Gene FunctionsTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 18007 Accepted: 10012DescriptionIt is well known that a human gene can be consider原创 2015-08-10 10:41:46 · 523 阅读 · 0 评论 -
POJ 2593&&2479:Max Sequence
Max SequenceTime Limit: 3000MS Memory Limit: 65536KTotal Submissions: 16329 Accepted: 6848DescriptionGive you N integers a1, a2 ... aN (|ai| You should原创 2015-07-05 14:47:57 · 724 阅读 · 0 评论 -
POJ 1837:Balance 天平DP。。。
BalanceTime Limit: 1000MS Memory Limit: 30000KTotal Submissions: 11878 Accepted: 7417DescriptionGigel has a strange "balance" and he wants to poise it. Actually原创 2015-08-04 23:00:48 · 720 阅读 · 0 评论 -
51nod1007:正整数分组 DP
1007 正整数分组基准时间限制:1 秒 空间限制:131072 KB 分值: 10 难度:2级算法题 收藏 关注将一堆正整数分为2组,要求2组的和相差最小。例如:1 2 3 4 5,将1 2 4分为1组,3 5分为1组,两组和相差1,是所有方案中相差最少的。Input第1行:一个数N,N为正整原创 2015-09-02 13:57:09 · 946 阅读 · 0 评论 -
POJ 1844:Sum ”滚动“数组
SumTime Limit: 1000MS Memory Limit: 30000KTotal Submissions: 10494 Accepted: 6895DescriptionConsider the natural numbers from 1 to N. By associating to each num原创 2015-09-08 20:43:48 · 343 阅读 · 0 评论 -
51nod 1022 石子归并 环形+四边形优化
1022 石子归并 V2基准时间限制:1 秒 空间限制:131072 KB 分值: 160 难度:6级算法题 收藏 关注N堆石子摆成一个环。现要将石子有次序地合并成一堆。规定每次只能选相邻的2堆石子合并成新的一堆,并将新的一堆石子数记为该次合并的代价。计算将N堆石子合并成一堆的最小代价。例如: 1 2 3 4,有不少合并方法原创 2015-09-23 14:31:27 · 1168 阅读 · 5 评论 -
HDU 1024:Max Sum Plus Plus 经典动态规划之最大M子段和
Max Sum Plus PlusTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 21336 Accepted Submission(s): 7130Problem DescriptionNow I t原创 2015-10-26 15:42:47 · 159 阅读 · 1 评论 -
HDU 5501:The Highest Mark 01背包
The Highest Mark Accepts: 71 Submissions: 197 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)问题描述2045年的SD省队选拔,赛制和三十年前已是完全不同。一场比赛的比赛时间有 t原创 2015-10-10 22:40:47 · 680 阅读 · 0 评论 -
hihocoder 1241:Best Route in a Grid
#1241 : Best Route in a Grid时间限制:10000ms单点时限:1000ms内存限制:256MB描述给定一个N行N列的非负整数方阵,从左上角(1,1)出发,只能向下或向右走,且不能到达值为0的方格,求出一条到达右下角的最佳路径。所谓最佳路径是指途经的数的乘积的末尾连续的0最少。输入输入文件的第一行包含原创 2015-10-13 08:45:22 · 451 阅读 · 0 评论 -
POJ 1276:Cash Machine 多重背包
Cash MachineTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 30006 Accepted: 10811DescriptionA Bank plans to install a machine for cash withdrawal. The原创 2015-09-17 10:11:04 · 425 阅读 · 0 评论 -
51nod1021:石子归并
1021 石子归并基准时间限制:1 秒 空间限制:131072 KB 分值: 20 难度:3级算法题 收藏 关注N堆石子摆成一条线。现要将石子有次序地合并成一堆。规定每次只能选相邻的2堆石子合并成新的一堆,并将新的一堆石子数记为该次合并的代价。计算将N堆石子合并成一堆的最小代价。例如: 1 2 3 4,有不少合并方法1 2原创 2015-09-06 15:22:16 · 559 阅读 · 0 评论 -
POJ 1738:An old Stone Game 石子归并(GarsiaWachs算法)
An old Stone GameTime Limit: 5000MS Memory Limit: 30000KTotal Submissions: 2981 Accepted: 796DescriptionThere is an old stone game.At the beginning of the game原创 2015-09-10 11:47:41 · 1368 阅读 · 0 评论 -
51nod 1006:最长公共子序列Lcs
1006 最长公共子序列Lcs基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 收藏 关注给出两个字符串A B,求A与B的最长公共子序列(子序列不要求是连续的)。比如两个串为:abcicbaabdkscabab是两个串的子序列,abc也是,abca也是,其中abca是这两个字原创 2015-09-10 10:51:06 · 1182 阅读 · 0 评论