UVA 10066 The Twin Towers
裸最长公共子序列
#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的更多相关文章
- uva 10066 The Twin Towers (最长公共子)
uva 10066 The Twin Towers 标题效果:最长公共子. 解题思路:最长公共子. #include<stdio.h> #include<string.h> # ...
- UVA.10066 The Twin Towers (DP LCS)
UVA.10066 The Twin Towers (DP LCS) 题意分析 有2座塔,分别由不同长度的石块组成.现在要求移走一些石块,使得这2座塔的高度相同,求高度最大是多少. 问题的实质可以转化 ...
- UVa 10192 - Vacation & UVa 10066 The Twin Towers ( LCS 最长公共子串)
链接:UVa 10192 题意:给定两个字符串.求最长公共子串的长度 思路:这个是最长公共子串的直接应用 #include<stdio.h> #include<string.h> ...
- UVA 10066 The Twin Towers(LCS)
Problem B The Twin Towers Input: standard input Output: standard output Once upon a time, in an anci ...
- LightOJ1126 Building Twin Towers(DP)
题目 Source http://www.lightoj.com/volume_showproblem.php?problem=1126 Description Professor Sofdor Al ...
- The Twin Towers zoj2059 DP
The Twin Towers Time Limit: 2 Seconds Memory Limit: 65536 KB Twin towers we see you standing ta ...
- ZOJ 2059 The Twin Towers(双塔DP)
The Twin Towers Time Limit: 2 Seconds Memory Limit: 65536 KB Twin towers we see you standing ta ...
- ZOJ 2059 The Twin Towers
双塔DP. dp[i][j]表示前i个物品,分成两堆(可以不全用),价值之差为j的时候,较小一堆的价值为dp[i][j]. #include<cstdio> #include<cst ...
- lightoj 1126 - Building Twin Towers(dp,递推)
题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1126 题解:一道基础的dp就是简单的递推可以设dp[height_left][ ...
随机推荐
- CSS继承总结
CSS的一个重要特征就是继承,它是依赖于祖先-后代的关系的.继承是一种机制,它允许样式不仅可以应用于某个特定的元素,还可以应用于它的后代. CSS可以继承的属性有: 1.文字相关:font-famil ...
- 如何建立一个完整的游戏AI
http://blog.friskit.me/2012/04/how-to-build-a-perfect-game-ai/ 人工智能(Artificial Intelligence)在游戏中使用已经 ...
- storyboard有多个Segue的传递
在项目中需要在一个页面向多个页面传不同的值. 在view2Controller和view3Controller中分别有相应的Str2和Str3 - (void)prepareForSegue:(UIS ...
- 10个php笔试题
Q1 第一个问题关于弱类型 $str1 = 'yabadabadoo'; $str2 = 'yaba'; if (strpos($str1,$str2)) { echo "/"&q ...
- django-cms安装
ubuntu:12.04 (32bit) djangocms 0.5.1 =========================== 首先,跟着这个做: https://github.com/divio/ ...
- 【转】【编码】ANSI,ASCII,Unicode,UTF8之一
不同的国家和地区制定了不同的标准,由此产生了 GB2312.GBK.GB18030.Big5.Shift_JIS 等各自的编码标准.这些使用多个字节来代表一个字符的各种汉字延伸编码方式,称 ...
- 使用Gitosis搭建Git服务器
使用Gitosis搭建Git服务器 作者: JeremyWei | 可以转载, 但必须以超链接形式标明文章原始出处和作者信息及版权声明 网址: http://weizhifeng.net/build- ...
- PHP的Tag标签
PHP的标签有至少四种:<?php ?>.<?= ?>.<script language="php"></script>.<? ...
- Shortest Palindrome
Given a string S, you are allowed to convert it to a palindrome by adding characters in front of it. ...
- Word Search I & II
Word Search I Given a 2D board and a word, find if the word exists in the grid. The word can be cons ...