#include<iostream> #include<cstdio> #include<cstring> #include<string> using namespace std; //LCS const int MAXN = 1005; int DP[MAXN][MAXN]; int main() { string a; string b; while(cin >> a >> b) { int l1 = a.size(); int
04年的省选这么water吗,开个滚动数组算了 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #define R(a,b,c) for(register int a = (b); a <= (c); ++ a) #define nR(a,b,c) for(register int a = (b);
Problem B The Twin Towers Input: standard input Output: standard output Once upon a time, in an ancient Empire, there were two towers of dissimilar shapes in two different cities. The towers were built by putting circular tiles one upon another. Each
一.最长公共子序列问题(LCS问题) 给定两个字符串A和B,长度分别为m和n,要求找出它们最长的公共子序列,并返回其长度.例如: A = "HelloWorld" B = "loop" 则A与B的最长公共子序列为 "loo",返回的长度为3.此处只给出动态规划的解法:定义子问题dp[i][j]为字符串A的第一个字符到第 i 个字符串和字符串B的第一个字符到第 j 个字符的最长公共子序列,如A为“app”,B为“apple”,dp[2][3]