UVA 10066 The Twin Towers LCS ,Commencel
来源:互联网 发布:网络性能测试仪 编辑:程序博客网 时间:2024/05/16 05:46
裸的LCS不解释
#include <map>#include <set>#include <list>#include <cmath>#include<cctype>#include <ctime>#include <deque>#include <stack>#include <queue>#include <cstdio>#include <string>#include <vector>#include <cstdlib>#include <cstring>#include <iostream>#include <algorithm>#define LL long long#define PI 3.1415926535897932626using namespace std;int gcd(int a, int b){return a % b == 0 ? b : gcd(b, a % b);}#define MAXN 110int N1,N2;int tower1[MAXN],tower2[MAXN];int dp[MAXN][MAXN];int main(){ //freopen("sample.txt","r",stdin); int kase=1; while (scanf("%d%d",&N1,&N2)!=EOF) { if (N1==0 && N2==0) break; for (int i=0;i<N1;i++) scanf("%d",&tower1[i]); for (int i=0;i<N2;i++) scanf("%d",&tower2[i]); memset(dp,0,sizeof(dp)); for (int i=1;i<=N1;i++) { for (int j=1;j<=N2;j++) if (tower1[i-1]==tower2[j-1]) { dp[i][j]=dp[i-1][j-1]+1; } else { dp[i][j]=max(dp[i][j-1],dp[i-1][j]); } } printf("Twin Towers #%d\n",kase++); printf("Number of Tiles : %d\n\n",dp[N1][N2]); } return 0;}
0 0
- UVA 10066 The Twin Towers LCS ,Commencel
- UVA 10066 The Twin Towers(dp + LCS)
- uva 10066 - The Twin Towers(LCS)
- UVa 10066 The Twin Towers (DP&LCS)
- UVA 10066 The Twin Towers (LCS)
- UVA.10066 The Twin Towers (DP LCS)
- UVa 10066 - The Twin Towers(LCS水题)
- UVA 10066 The Twin Towers 双塔 LCS,dp
- UVA - 10066 - The Twin Towers (动态规划, LCS)
- uva 10066 The Twin Towers(动态规划:LCS)
- UVA 10066 - The Twin Towers
- uva 10066 The Twin Towers
- UVA 10066 The Twin Towers
- UVA 10066 The Twin Towers
- UVa 10066 - The Twin Towers
- UVa 10066 - The Twin Towers
- UVa 10066 - The Twin Towers
- UVa 10066 - The Twin Towers
- 简单工厂模式 ,策略模式 实现计算器
- 除去字符串中的所有空格
- HDU 2159 完全背包模板题
- linux系统下载 仅供学习测试
- 成绩最大
- UVA 10066 The Twin Towers LCS ,Commencel
- SOAP1.1和SOAP1.2的区别
- linux学习之使用RHCS套件搭建HA高可用集群
- HttpClient之参数设置
- 网站建设中用户经常会纠结的问题有哪些
- Struts2中s标签的用法
- leetcode-Remove Element
- 数据库-mysql--IP address 'xxx.xxx.xxx.xx' could not be resolved: getnameinfo() returned error (code: -3
- 机器学习中的范数规则化之(一)L0、L1与L2范数