裸最长公共子序列

 #include<time.h>
#include <cstdio>
#include <iostream>
#include<algorithm>
#include<math.h>
#include <string.h>
#include<vector>
#include<queue>
using namespace std; int dp[][];
int map1[],map2[]; int main()
{
int num1,num2;
int cas=;
while(~scanf("%d %d",&num1,&num2))
{
if(num1== && num2==)
break;
memset(dp,,sizeof(dp));
for(int i=;i<num1;i++)
scanf("%d",&map1[i]);
for(int j=;j<num2;j++)
scanf("%d",&map2[j]); for(int i=;i<num1;i++)
for(int j=;j<num2;j++)
{
if(map1[i]==map2[j])
dp[i+][j+]=dp[i][j]+;
else
dp[i+][j+]=max(dp[i][j+],dp[i+][j]);
}
printf("Twin Towers #%d\nNumber of Tiles : %d\n\n",cas++,dp[num1][num2]);
}
return ;
}

UVA 10066 The Twin Towers的更多相关文章

  1. uva 10066 The Twin Towers (最长公共子)

    uva 10066 The Twin Towers 标题效果:最长公共子. 解题思路:最长公共子. #include<stdio.h> #include<string.h> # ...

  2. UVA.10066 The Twin Towers (DP LCS)

    UVA.10066 The Twin Towers (DP LCS) 题意分析 有2座塔,分别由不同长度的石块组成.现在要求移走一些石块,使得这2座塔的高度相同,求高度最大是多少. 问题的实质可以转化 ...

  3. UVa 10192 - Vacation &amp; UVa 10066 The Twin Towers ( LCS 最长公共子串)

    链接:UVa 10192 题意:给定两个字符串.求最长公共子串的长度 思路:这个是最长公共子串的直接应用 #include<stdio.h> #include<string.h> ...

  4. UVA 10066 The Twin Towers(LCS)

    Problem B The Twin Towers Input: standard input Output: standard output Once upon a time, in an anci ...

  5. LightOJ1126 Building Twin Towers(DP)

    题目 Source http://www.lightoj.com/volume_showproblem.php?problem=1126 Description Professor Sofdor Al ...

  6. The Twin Towers zoj2059 DP

    The Twin Towers Time Limit: 2 Seconds      Memory Limit: 65536 KB Twin towers we see you standing ta ...

  7. ZOJ 2059 The Twin Towers(双塔DP)

    The Twin Towers Time Limit: 2 Seconds      Memory Limit: 65536 KB Twin towers we see you standing ta ...

  8. ZOJ 2059 The Twin Towers

    双塔DP. dp[i][j]表示前i个物品,分成两堆(可以不全用),价值之差为j的时候,较小一堆的价值为dp[i][j]. #include<cstdio> #include<cst ...

  9. lightoj 1126 - Building Twin Towers(dp,递推)

    题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1126 题解:一道基础的dp就是简单的递推可以设dp[height_left][ ...

随机推荐

  1. vim 编辑器的设置

    vi编辑器的配置:http://blog.mcuol.com/User/fenghua/Article/17411_1.htm ******************************vim ~/ ...

  2. Gunicorn 和 Nginx

    Web Application Deployment Using Nginx Nginx is a very high performant web server / (reverse)-proxy. ...

  3. word20161204

    CA, certification authority / 证书颁发机构 cache / 高速缓存 cache file / 缓存文件 caching / 缓存 caching resolver /  ...

  4. JavaScript深入浅出2-表达式和运算符

    慕课网教程视频地址:Javascript深入浅出 表达式是指能计算出值的任何可用程序单元 原始表达式:常量.直接量 3.14,“test” 关键字 null,this 变量 i,k,j 表达式含:原始 ...

  5. BZOJ 1355: [Baltic2009]Radio Transmission

    Description 一个字符串最短周期. Sol KMP. 最短周期就是 \(n-next[n]\) 证明: 当该字符串不存在周期的时候 \(next[n]=0\) 成立. 当存在周期的时候 \( ...

  6. js原生的url操作函数,及使用方法。(附:下边还有jquery对url里的中文解码函数)

    js原生的url操作函数,完善的. /*****************************/ /* 动态修改url */ /*****************************/ var ...

  7. js控制精度的加减乘除:js浮点数计算问题

    //加法函数 function accAdd(arg1, arg2) { var r1, r2, m; try { r1 = arg1.toString().split(".")[ ...

  8. gitlab 无法查看提交的文件Errno::ENOMEM (Cannot allocate memory - /opt/gitlab/embedded/bin/git):

    gitlab可以成功clone和push,但是提交后的文件却无法查看.从页面上看的话只显示出500错误. 查了下gitlab的日志 tail -f /var/log/gitlab/gitlab-rai ...

  9. java学习笔记--IO流

    第十二章大纲: I/O input/output 输入/输出 一.创建文件,借助File类来实现 file.createNewFile() : 创建文件 file.exists() : 判断文件是否存 ...

  10. codeforces 515B. Drazil and His Happy Friends 解题报告

    题目链接:http://codeforces.com/problemset/problem/515/B 题目意思:有 n 个 boy 和 m 个 girl,有 b 个 boy 和 g 个 girl ( ...