POJ 1458 解题报告
来源:互联网 发布:李华明编程厉害不 编辑:程序博客网 时间:2024/04/19 13:32
这道题是求Longest Common Sequence,之前已经做过许多遍了。
1458Accepted364K16MSC++918B/* ID: thestor1 LANG: C++ TASK: poj1458 */#include <iostream>#include <fstream>#include <cmath>#include <cstdio>#include <cstring>#include <limits>#include <string>#include <vector>#include <list>#include <set>#include <map>#include <queue>#include <stack>#include <algorithm>#include <cassert>using namespace std;int lcs(string &str1, string &str2){std::vector<std::vector<int> > dp(str1.size() + 1, std::vector<int>(str2.size() + 1, 0));for (int i = 1; i <= str1.size(); ++i){for (int j = 1; j <= str2.size(); ++j){if (str1[i - 1] == str2[j - 1]){dp[i][j] = dp[i - 1][j - 1] + 1;}else{dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);}}}return dp[str1.size()][str2.size()];}int main(){string str1, str2;while (cin >> str1 >> str2){cout << lcs(str1, str2) << endl;}return 0; }
0 0
- POJ 1458解题报告
- POJ 1458 解题报告
- poj解题报告——1458
- poj数百篇解题报告
- poj 1141解题报告
- poj 1001解题报告
- poj 1011 解题报告
- poj 1087 解题报告
- poj 2153解题报告
- poj 2051解题报告
- POJ 1167 解题报告
- poj 1026 解题报告
- POJ 1077 解题报告
- POJ 1042 解题报告
- POJ 1095 解题报告
- POJ 1159解题报告
- poj 2312解题报告
- POJ 1001解题报告
- 增进夫妻感情的小方法
- ransac估计(之二)
- 哦哦哦哦哦哦哦哦哦哦哦哦哦
- JAVA读GZ文件
- bp神经网络及matlab实现
- POJ 1458 解题报告
- java中的io系统
- android布局笔记,不断更新
- 配置mysql的密码
- Lua学习之8:控制语句
- 有关dwt文件和lbi文件的理解和区别
- 三层架构中DataTable华丽变身泛型集合
- javabase简记- 第三天
- Mondrian缓存的处理