标签:contains while contest accept otto ane number input common
上次写题解写到一半,写的比较具体,没写完,忘记存草稿了。。。导致现在没心情了。
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 39661 Accepted Submission(s): 18228
#include<bits/stdc++.h> using namespace std; const int N=1e3+10; char s1[N],s2[N]; int dp[N][N]; int len1,len2; void fun(){ memset(dp,0,sizeof(dp)); 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 dp[i][j]=max(dp[i-1][j],dp[i][j-1]); } } } int main(){ while(~scanf("%s%s",&s1,&s2)){ len1=strlen(s1); len2=strlen(s2); fun(); printf("%d\n",dp[len1][len2]); } return 0; }
HDU1159-Common Subsequence-LCS
标签:contains while contest accept otto ane number input common
原文地址:http://www.cnblogs.com/ZERO-/p/7207653.html