HDU 1159 Common Subsequence(LCS)
2016-09-14 22:19
447 查看
// // main.cpp // Richard // // Created by 邵金杰 on 16/9/14. // Copyright © 2016年 邵金杰. All rights reserved. // #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int maxn=1000+10; int dp[maxn][maxn]; char s1[maxn],s2[maxn]; int main() { while(scanf("%s%s",s1+1,s2+1)!=EOF) { memset(dp,0,sizeof(dp)); int len1=(int)strlen(s1+1); int len2=(int)strlen(s2+1); for(int i=1;i<=len1;i++) dp[i][0]=0; for(int i=1;i<=len2;i++) dp[0][i]=0; for(int i=1;i<=len1;i++){ for(int j=1;j<=len2;j++){ if(s1[i]==s2[j]) dp[i][j]=dp[i-1][j-1]+1; else dp[i][j]=max(dp[i-1][j],dp[i][j-1]); } } cout<<dp[len1][len2]<<endl; } return 0; }
相关文章推荐
- hdu 1159 Common Subsequence(lcs)
- HDU 1159 Common Subsequence (LCS)
- hdu1159 Common Subsequence(LCS)
- HDU1159 && POJ1458:Common Subsequence(LCS)
- HDU 1159 Common Subsequence(LCS)
- HDU 1159 Common Subsequence(LCS)
- [HDU - 1159] Common Subsequence(动态规划&&LCS)
- hdu1159 Common Subsequence(LCS)
- HDU 1159 Common Subsequence(LCS)
- HDU 1159 Common Subsequence【LCS(dp)】
- hdu 1159 && POJ 1458Common Subsequence(LCS)
- hdu 1159 && poj 1458 Common Subsequence (LCS)
- HDU 1159 Common Subsequence(LCS)
- hdu 1159 Common Subsequence(LCS)
- HDU1159-Common Subsequence-LCS
- Common Subsequence HDU - 1159 (lcs简单dp)
- HDU1159 && POJ1458 Common Subsequence (LCS)
- HDU 1159 Common Subsequence (线性dp 裸LCS)
- HDU 1159 Common Subsequence(LCS 模板题)
- 【hdu 1159】Common Subsequence(LCS模板)