标签:
abcfbc abfcab programming contest abcd mnp
4 2 0
#include<iostream> #include<cstdio> #include<cstring> using namespace std; char x[1001],y[1001]; int c[1001][1001]; int l1,l2; int main() { while(scanf("%s%s",x+1,y+1)==2){ memset(c,0,sizeof(c)); l1=strlen(x+1);l2=strlen(y+1); for(int i=1;i<=l1;i++) for(int j=1;j<=l2;j++) if(x[i]==y[j]) c[i][j]=c[i-1][j-1]+1; else c[i][j]=max(c[i-1][j],c[i][j-1]); printf("%d\n",c[l1][l2]);} return 0; }
标签:
原文地址:http://www.cnblogs.com/shenben/p/5564861.html