Description:
Accept:
#include<bits/stdc++.h>
using namespace std;
string a, b;
const int maxn=1010;
int dp[maxn][maxn], n, m;
int Max_s(int i, int j){
if(dp[i][j]!=-1)return dp[i][j];
if(i==n)return dp[i][j]=0;
if(j==m)return dp[i][j]=0;
if(a[i]==b[j])return dp[i][j]=Max_s(i+1, j+1)+1;
dp[i][j]=max(Max_s(i+1, j), Max_s(i, j+1));
return dp[i][j];
}
int main()
{
while(cin>>a>>b){
memset(dp, -1, sizeof(dp));
n=a.length();
m=b.length();
printf("%d\n", Max_s(0, 0));
}
return 0;
}