Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
附代码!!#include<stdio.h> #include<string.h> #include<iostream> #define ma(a,b) a>b?a:b; using namespace std; int dp[513][522]; int main() { int a,n,m,i,j; char s1[2222],s2[2222]; while(~scanf("%s %s",s1,s2)) { if(s1[0]=='0') break; int l1=strlen(s1); int l2=strlen(s2); memset(dp,0,sizeof(dp)); for(i=0;i<l1;i++) for(j=0;j<l2;j++) { if(s1[i]==s2[j]) { dp[i+1][j+1]=dp[i][j]+1; }else{ dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]); } } printf("%d\n",dp[l1][l2]); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator