随笔分类 -  动态规划

摘要:描述给定一整型数列{a1,a2...,an},找出连续非空子串{ax,ax+1,...,ay},使得该子序列的和最大,其中,1<=x<=y<=n。 阅读全文
posted @ 2017-08-09 19:40 ⊙∽⊙Perseverance 阅读(147) 评论(0) 推荐(0)
摘要:描述咱们就不拐弯抹角了,如题,需要你做的就是写一个程序,得出最长公共子序列。tip:最长公共子序列也称作最长公共子串(不要求连续),英文缩写为LCS(Longest Common Subsequence)。其定义是,一个序列 S ,如果分别是两个或多个已知序列的子序列,且是所有符合此条件序列中最长的 阅读全文
posted @ 2017-08-09 17:59 ⊙∽⊙Perseverance 阅读(168) 评论(0) 推荐(0)
摘要:描述求一个字符串的最长递增子序列的长度如:dabdbf最长递增子序列就是abdf,长度为4 阅读全文
posted @ 2017-08-09 17:33 ⊙∽⊙Perseverance 阅读(124) 评论(0) 推荐(0)
摘要:某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的高度.某天,雷达捕捉到敌国的导弹来袭.由于该系统还在试用阶段,所以只有一套系统,因此有可能不能拦截所有的导弹. 怎么办呢?多搞几套系统呗!你说 阅读全文
posted @ 2017-08-09 15:29 ⊙∽⊙Perseverance 阅读(83) 评论(0) 推荐(0)
摘要:Problem Description Given 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 阅读全文
posted @ 2017-08-08 20:47 ⊙∽⊙Perseverance 阅读(61) 评论(0) 推荐(0)
摘要:"OK, you are not too bad, em... But you can never pass the next test." feng5166 says. "I will tell you an odd number N, and then N integers. There wil 阅读全文
posted @ 2017-08-08 11:06 ⊙∽⊙Perseverance 阅读(128) 评论(0) 推荐(0)
摘要:Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Maybe you are a good boy, and know little about this 阅读全文
posted @ 2017-08-08 11:03 ⊙∽⊙Perseverance 阅读(160) 评论(0) 推荐(0)
摘要:鹏神意外得到了神灯。 神灯中冒出了灯神,灯神说道:“我将给你一个有序的数列,你可以在保证原有顺序不变的前提下,挑出任意多的数。如果你挑出的数字是严格升序的,那么这段数字的个数就是你女朋友的个数。” “妈的智障。”鹏神骂道。 但是鹏神还是希望自己能有尽可能多的女朋友。所以他求救于你,希望你能帮他算出他 阅读全文
posted @ 2017-08-08 10:58 ⊙∽⊙Perseverance 阅读(107) 评论(0) 推荐(0)
摘要:1 /* 2 LCS 3 4 BDCABA 5 ABCBDAB 6 7 dp[1][2] = 1 8 dp[1][1] = 0 9 dp[2][1] = 0 10 11 //子串:连续 12 //子序列:可以不连续 13 // LCS 14 15 dp[i][j]//第一个字符串在第i个字符前且第二个串在第j个字符前可构成的最长子序列的长度 16 17 dp[i]... 阅读全文
posted @ 2017-08-08 10:19 ⊙∽⊙Perseverance 阅读(476) 评论(0) 推荐(0)
摘要:A subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = < x1, x2, ..., xm > another 阅读全文
posted @ 2017-08-08 10:15 ⊙∽⊙Perseverance 阅读(146) 评论(0) 推荐(0)