For example, Z = < a, b, f, c > is a subsequence of X = < a, b, c, f, b, c > with index sequence < 1, 2, 4, 6 >. Given two sequences X and Y the problem is to find the length of the maximum-length common subsequence of X and Y. InputThe program input is from...
代码: #include<cstdio>#include<cstring>#include<iostream>#include<string>#include<algorithm>usingnamespacestd;constintMAXN=3e2+10;constintINF=0x3f3f3f3f;chars[MAXN];chart[MAXN];intdp[MAXN][MAXN];voidLCS(intlen1,intlen2){for(inti=0;i<len1;++i){for(intj=0;j<len2;++j){if(s[...
HDU 1159 && POJ 1458 最长公共子序列。状态转移方程见代码。 代码解读 #include <iostream> #include <cstdio> #include <cstring> using namespace std; char s1[1005],s2[1005]; int dp[1005][1005]; int main() { while(scanf("%s",s1+1)!=EOF) { scanf("%s",s2+1); memset(dp,0,sizeof...