#include <cstdio>
#include <cstdlib>
#include <cstring>
#define max(a,b) (((a) > (b)) ? (a) : (b))
const int MAXN = 1010;
char s[MAXN], d[MAXN];
int dp[MAXN][MAXN];
int main()
{
while (gets(s+1) && gets(d+1))
{
int ls = strlen(s + 1);
int ld = strlen(d + 1);
memset(dp, 0, sizeof(dp));
for (int i = 1; i <= ls; ++i)
for (int j = 1; j <= ld; ++j)
if (s[i] == d[j])
dp[i][j] = dp[i-1][j-1] + 1;
else
dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
printf("%d\n", dp[ls][ld]);
}
return 0;
}
-------------------------------------------------------
kedebug
Department of Computer Science and Engineering,
Shanghai Jiao Tong University
E-mail: kedebug0@gmail.com
GitHub: http://github.com/kedebug
-------------------------------------------------------