HDOJ 1159 Common Subsequence
来源:互联网 发布:airplayer for mac 编辑:程序博客网 时间:2024/04/28 17:18
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1159
直接用最长公共子序列问题的模板直接水之
关于最长公共子序列问题在我的博客里有详解:http://blog.csdn.net/jiahui524/article/details/6653181
源代码:
//HDOJ 1159#include <iostream>using namespace std;#define N 1005//汗,开105 说什么运行时错误int dp[N+1][N+1];char str1[N],str2[N];int maxx(int a,int b){if(a>b){return a;}return b;}int LCSL(int len1,int len2){int i,j;int len=maxx(len1,len2);for(i=0;i<=len;i++){dp[i][0]=0;dp[0][i]=0;}for(i=1;i<=len1;i++){for(j=1;j<=len2;j++){if(str1[i-1]==str2[j-1]){dp[i][j]=dp[i-1][j-1]+1;}else{dp[i][j] = maxx(dp[i - 1][ j ] , dp[i][j - 1]) ; }}}return dp[len1][len2];}int main(){while(cin>>str1>>str2){int len1=strlen(str1);int len2=strlen(str2);cout<<LCSL(len1,len2)<<endl;}return 0;}
- HDOJ 1159:Common Subsequence
- hdoj 1159 Common Subsequence
- HDOJ 1159 Common Subsequence
- HDOJ 1159 Common Subsequence
- hdoj 1159 Common Subsequence
- HDOJ 1159 Common Subsequence
- HDOJ 1159 Common Subsequence
- HDOJ-----1159Common Subsequence
- hdoj 1159 Common Subsequence 【LCS】
- PKU 1458 HDOJ 1159 Common Subsequence
- POJ 1458 || HDOJ 1159 Common Subsequence (DP)
- HDOJ 1159 Common Subsequence 杭电 ACM
- poj 1458 hdoj 1159 Common Subsequence
- HDOJ 1159 Common Subsequence(水DP,LCS)
- Common Subsequence —— hdoj 1159
- HDOJ 1159 Common Subsequence解题报告
- HDOJ Common Subsequence 1159【详细分析LCS】
- HDOJ 题目1159 Common Subsequence(LCS)
- TreeView节点快速访问之道
- JQuery 创建节点的办法
- SWFUpload V2.2.0 说明文档
- Linux IPC总结(全)
- XtraTreeList使用扎记(2)
- HDOJ 1159 Common Subsequence
- Android杂谈---关于drawable文件夹的错误
- TreeList使用扎记(3)
- XtreTreeList使用扎记(四)
- 原来是项目属性里的运行库设置的原因
- Android 开发学习视频教程
- java内存泄露
- 如何将org.w3c.dom.Element xml节点对象转化成XML格式的string字符串
- TreeList之Extjs篇