标签:style blog http io ar color os sp for
2 asdf adfsd 123abc abc123abc
3 6
#include<stdio.h> #include<string.h> #include<algorithm> using namespace std; int dp[1002][1002]; int main() { char a[1002],s[1002]; int lena,lens,i,j,test; scanf("%d",&test); while(test--) { scanf("%s %s",a,s); lena=strlen(a); lens=strlen(s); memset(dp,0,sizeof(dp)); for(i=1;i<=lena;i++) { for(j=1;j<=lens;j++) { if(a[i-1]==s[j-1]) dp[i][j]=dp[i-1][j-1]+1; else dp[i][j]=max(dp[i-1][j],dp[i][j-1]); } } printf("%d\n",dp[lena][lens]); } return 0; }
标签:style blog http io ar color os sp for
原文地址:http://blog.csdn.net/hdd871532887/article/details/41804613