HDU 1159 Common Subsequence(LCS)
来源:互联网 发布:日本皇族知乎 编辑:程序博客网 时间:2024/05/16 06:43
题目链接:HDU 1159 Common Subsequence
最长公共子序列。
模版题。
#include <iostream>#include <cstring>using namespace std;const int MAX_N = 1000 + 100;char a[MAX_N],b[MAX_N];int dp[MAX_N][MAX_N];int main(){ while(cin >> a >> b) { int len1 = strlen(a); int len2 = strlen(b); for(int i = 0;i <= len1;i++) dp[i][0] = 0; for(int j = 0;j <= len2;j++) dp[0][j] = 0; for(int i = 1;i <= len1;i++) { for(int j = 1;j <= len2;j++) { if(a[i - 1] == b[j - 1]) 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;}
0 0
- hdu 1159 Common Subsequence (LCS)
- HDU 1159 Common Subsequence(LCS)
- hdu 1159 Common Subsequence(LCS)
- HDU 1159 Common Subsequence【LCS】
- hdu 1159 Common Subsequence (lcs)
- hdu 1159 Common Subsequence(lcs)
- HDU-1159-Common Subsequence【LCS】
- HDU 1159 Common Subsequence(LCS)
- HDU 1159 Common Subsequence(LCS)
- HDU 1159 Common Subsequence (LCS)
- HDU 1159 Common Subsequence (动态规划LCS)
- HDU 1159 Common Subsequence(LCS)
- hdu 1159 Common Subsequence 【LCS 基础入门】
- hdu 1159 && poj 1458 Common Subsequence (LCS)
- HDU 1159 Common Subsequence(DP,LCS)
- hdu 1159 Common Subsequence(LCS,dp)
- HDU - 1159 Common Subsequence (简单LCS)
- HDU 1159 Common Subsequence(dp LCS)
- Windows下一个并发阻塞队列(BlockingQueue)
- 用shell脚本为ubuntu自动添加用户,并限定通过ssh连接该用户只能执行特定某个(或某几个)程序
- shape、selector的使用
- maven - package a jar with main class
- 使用UINavigationController后导致UIScollView尺寸变化(转)
- HDU 1159 Common Subsequence(LCS)
- Qt读写二进制文件
- ndk-build all Error: Cannot run program "ndk-build": Launching failed
- 从腾讯微信商标“失守”谈商标管理
- 【OpenCV入门教程之五】 分离颜色通道&多通道图像混合
- 啊哈!算法】最快最简单的排序——桶排序
- IOS 添加字体
- Verilog编程规范(补充中)
- JFreeChart 属性