标签:logs div const space ace main tor set 子序列
#include<map> #include<set> #include<list> #include<cmath> #include<queue> #include<stack> #include<vector> #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #define ll long long using namespace std; const int N=100; int dp[N][N]; int main() { char s1[N],s2[N]; int l1,l2; while(~scanf("%s%s",&s1,&s2)){ l1=strlen(s1); l2=strlen(s2); memset(dp,0,sizeof(dp)); for(int i=1;i<=l1;i++) for(int j=1;j<=l2;j++) { if(s1[i-1]==s2[j-1])dp[i][j]=dp[i-1][j-1]+1; else dp[i][j]=max(dp[i-1][j],dp[i][j-1]); } /* for(int i=0;i<=l1;i++) { for(int j=0;j<=l2;j++) { printf("%d ",dp[i][j]); } printf("\n"); }*/ printf("%d\n",dp[l1][l2]); } return 0; }
标签:logs div const space ace main tor set 子序列
原文地址:http://www.cnblogs.com/acjiumeng/p/6538803.html