POJ1458 Common Subsequence
来源:互联网 发布:九流社区软件 编辑:程序博客网 时间:2024/05/17 06:49
URL : http://poj.org/problem?id=1458
LCS 的水题,做另外一个动态规划题没思路,就找到了它放松下脑子,代码:
#include <cstdio>#include <iostream>#include <string>using namespace std;int main(){ string s1, s2; while(cin >> s1 >>s2){ int m = s1.size(), n = s2.size(); int LCS[m+1][n+1]; for(int i = 0; i <= n; i++) LCS[0][i] = 0; for(int j = 0; j <= m; j++) LCS[j][0] = 0; for(int i = 1; i <= m; i++) for(int j = 1; j <= n; j++) if(s1[i-1] == s2[j-1]) LCS[i][j] = LCS[i-1][j-1] + 1; else LCS[i][j] = LCS[i][j-1] > LCS[i-1][j] ? LCS[i][j-1] : LCS[i-1][j]; printf("%d\n", LCS[m][n]); } return 0;}
0 0
- poj1458 dp Common Subsequence
- poj1458 - Common Subsequence
- poj1458(Common Subsequence)
- POJ1458 Common Subsequence
- POJ1458--Common Subsequence
- POJ1458 Common Subsequence
- Common Subsequence(poj1458)
- POJ1458 Common Subsequence
- POJ1458 Common Subsequence
- POJ1458 Common Subsequence
- Common Subsequence(poj1458)
- POJ1458 Common Subsequence DP
- POJ1458 Common Subsequence
- poj1458 Common Subsequence【LCS】
- POJ1458 Common Subsequence
- POJ1458 Common Subsequence
- POJ1458 Common Subsequence
- poj1458 Common Subsequence
- 剑指offer 面试题7 两个栈实现队列
- An Introduction to Bioinformatics Algorithms - I - page1-78
- QT 国际化,多语言平台的支持
- POJ 2492 || HDU 1829:A Bug's Life(并查集)
- HDU4570 Multi-bit Trie 区间DP
- POJ1458 Common Subsequence
- 3-1. 三天打鱼两天晒网(15)
- HDU 1232 畅通工程 (幷查集)
- 吸电流、拉电流、灌电流、上拉电阻、下拉电阻、高阻态等基础知识普及
- Netty In Action中文版 - 第四章:Transports(传输)
- 20140714 「初等数论 - 卡特兰数」 POJ 2084 Game of Connections
- java中UUID的生成
- pyhton———使用urllib 下载文件~~过掉岁月过掉风
- 黑马程序员-Java中使用反射生成并操作对象