裸最长公共子序列

 #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. Java多线程基础知识(二)

    一. Java线程具有6种状态  NEW 初始状态,线程被创建,但是还没有调用start方法. RUNNABLE 运行状态,java线程将操作系统中的就绪和运行两种状态笼统的称作进行中. BLOCKE ...

  2. Android开发学习笔记--一个有界面A+B的计算器

    做了一个A+B的APP,虽然很简单,但是作为初学者还是弄了几个小时才弄好,什么东西都要看书或者百度,但最后成功了,还是很开心的,收货蛮大的.现在把过程写一下: 首先给出效果图: 一开始布局一直有问题, ...

  3. PHP微信支付开发实例

    这篇文章主要为大家详细介绍了PHP微信支付开发过程,具有一定的参考价值,感兴趣的小伙伴们可以参考一下 PHP微信支付开发过程,分享给大家,供大家参考,具体内容如下 1.开发环境 Thinkphp 3. ...

  4. BZOJ 3665: maths

    Sol 矩阵乘法+快速幂+欧拉定理. 首先观察题目可以发现 \(A_n\) 可以表示成关于 \(K\) 和 \(A_0\) 的几次幂的形式. \(A_0\) 就比较简单了 \(m^n\) 所以第一部分 ...

  5. gcc编译时对'xxxx'未定义的引用问题

    gcc编译时对’xxxx’未定义的引用问题 gcc编译时对’xxxx’未定义的引用问题 原因 解决办法 gcc 依赖顺序问题 在使用gcc编译的时候有时候会碰到这样的问题,编译为.o(obj) 文件没 ...

  6. 简单的哈希表实现 C语言

    简单的哈希表实现 简单的哈希表实现 原理 哈希表和节点数据结构的定义 初始化和释放哈希表 哈希散列算法 辅助函数strDup 哈希表的插入和修改 哈希表中查找 哈希表元素的移除 哈希表打印 测试一下 ...

  7. 5.5---整数A转成整数B(CC150)

    自己的: public static int calcCost(int A,int B){ int ans = 1; int temp = A ^ B; while(temp != 1){ if(te ...

  8. Graph Valid Tree

    Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), ...

  9. 【Unity3D】Invoke,InvokeRepeating ,Coroutine 延迟调用,周期性调用

    Invoke和InvokeRepeating方法,可以实现延迟调用,和周期调用 第一个是执行一次,第二个是重复执行 void Invoke(string methodName, float time) ...

  10. Qt Connect 信号 槽

    信号和槽机制是 QT 的核心机制 .信号和槽是一种高级接口,应用于对象之间的通信,它是 QT 的核心特性,也是 QT 区别于其它工具包的重要地方.信号和槽是 QT 自行定义的一种通信机制,它独立于标准 ...