
LCS
文章平均质量分 50
空白君有着一把空白键blanKey
即使世界如此残酷,我们仍是努力挣扎着
/*算了,退役了,不挣扎了QWQ*/
展开
-
hdu1159 Common Subsequence(LCS)
LCS的无敌大水题#include <iostream>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>#include <algorithm>using namespace std;#define maxn 500int dp[maxn][maxn];char str1[maxn],原创 2015-11-03 22:01:45 · 387 阅读 · 0 评论 -
hdu1503 Advanced Fruits (简单LCS)
典型最长公共子序列。#include <iostream>#include <stdio.h>#include <string.h>#include <math.h>#include <stdlib.h>#include <algorithm>using namespace std;#define maxn 105int dp[maxn][maxn];char str1[maxn]原创 2015-11-03 21:16:32 · 625 阅读 · 0 评论 -
hdu5791 Two(DP,LCS)
题目点我点我点我题目大意:两个序列的公共子序列数目。解题思路:dp[i][j]表示A序列和B序列在Ai,Bj时公共子序列的数目。状态转移方程:dp[i][j] += (dp[i-1][j] - dp[i-1][j-1] + dp[i][j-1] + (A[i] == B[j] ? dp[i - 1][j - 1] + 1 : 0) )注意取模。/原创 2016-08-02 19:50:34 · 366 阅读 · 0 评论 -
HDU5904 LCIS (DP)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=5904题目大意:给定两个序列,求最长的公共上升子序列,这个子序列公差是1.解题思路:从前往后DP,dp[i]表示以i结尾的最长上升子序列的长度。dp[val] = dp[val-1] + 1。分别对两个串进行DP。然后对于每一个最长上升子序列的结尾的值i取原创 2016-10-03 13:20:22 · 386 阅读 · 0 评论