http://acm.hdu.edu.cn/showproblem.php?pid=1159
#include <stdio.h>
#include <string.h>
int dp[1100][1100];
int main()
{
char s1[1100],s2[1100];
while(~scanf("%s %s",s1,s2))
{
memset(dp,0,sizeof(dp));
int len1 = strlen(s1);
int len2 = strlen(s2);
for(int i = 1; i <= len1; i++)
{
for(int j = 1; j <= len2; j++)
{
if(s1[i-1] == s2[j-1])
dp[i][j] = dp[i-1][j-1] + 1;
else
{
if(dp[i-1][j] > dp[i][j-1])
dp[i][j] = dp[i-1][j];
else dp[i][j] = dp[i][j-1];
}
}
}
printf("%d\n",dp[len1][len2]);
}
return 0;
}