【DP】poj1458
来源:互联网 发布:plsql导入数据和表结构 编辑:程序博客网 时间:2024/06/17 06:44
基础的lcs问题。。。
至于lcs是什么。。。。百度好了啊。。
话说应该有一篇报告是写了怎么推到(推导)lcs公式的
所以就随便粘个代码吧
#include<iostream>#include<cstdio>#include<cstring>#include<cmath>#include<cstdlib>#include<algorithm>using namespace std;int f[1010][1010],len1,len2,maxf;char s[3][2010];int main(){ while (scanf("%s ",s[1])!=EOF) { memset(f,0,sizeof(f)); f[0][0]=0; maxf=0; scanf("%s ",s[2]); len1=strlen(s[1]); len2=strlen(s[2]); for (int i=1;i<=len1;i++) for (int j=1;j<=len2;j++) { if (s[1][i-1]==s[2][j-1]) f[i][j]=f[i-1][j-1]+1; else f[i][j]=max(f[i-1][j],f[i][j-1]); maxf=max(maxf,f[i][j]); } printf("%d\n",maxf); memset(s,0,sizeof(s)); } //cin>>maxf; return 0;}顺便膜拜一下FINAL AK的T神。。。。。去final这种事情对于蒟蒻果然只是梦想吗。。
0 0
- poj1458 dp
- 【DP】poj1458
- poj1458 dp Common Subsequence
- DP---(POJ1159 POJ1458 POJ1141)
- POJ1458 Common Subsequence DP
- poj1458 LCS 基础dp
- poj1458 Common Subsequence(经典DP)
- [dp]poj1458 -Common Subsequence(LCS)
- POJ1458--Common Subsequence(dp)
- poj1458
- POJ1458
- poj1458
- poj1458
- poj1458
- poj1458
- poj1458
- poj1458
- poj1458
- 同伴与伙伴
- 判断字符串是否为合法ip
- 4412 矩阵键盘
- ie浏览器的标准模式与怪异模式的设置与区分方法
- css vertical-align属性详解
- 【DP】poj1458
- iOS Crash 分析(文一)- 开始
- 字符串中sizeof和strlen的区别,以及'\0'与NULL的区别
- GridView详解
- std::function
- 单纯地“世故”——laugh off & see through
- 详细分析Hibernate的merge()方法
- 天梯匹配算法的思路
- 第3章40题