UVA 10192 Vacation
裸最长公共子序列
#include<time.h>
#include <cstdio>
#include <iostream>
#include<algorithm>
#include<math.h>
#include <string.h>
#include<vector>
#include<queue>
#include<set>
#include<iterator>
using namespace std; int dp[][];
char str1[],str2[]; int main()
{
int len1,len2;
int cas=;
while(gets(str1))
{ if(str1[]=='#')
break;
gets(str2);
memset(dp,,sizeof(dp));
len1=strlen(str1);
len2=strlen(str2); for(int i=;i<len1;i++)
for(int j=;j<len2;j++)
{
if(str1[i]==str2[j])
dp[i+][j+]=dp[i][j]+;
else
dp[i+][j+]=max(dp[i][j+],dp[i+][j]);
}
printf("Case #%d: you can visit at most %d cities.\n",cas++,dp[len1][len2]);
}
return ;
}
UVA 10192 Vacation的更多相关文章
- uva 10192 Vacation(最长公共子)
uva 10192 Vacation The Problem You are planning to take some rest and to go out on vacation, but you ...
- UVA.10192 Vacation (DP LCS)
UVA.10192 Vacation (DP LCS) 题意分析 某人要指定旅游路线,父母分别给出了一系列城市的旅游顺序,求满足父母建议的最大的城市数量是多少. 对于父母的建议分别作为2个子串,对其做 ...
- UVa 10192 - Vacation & UVa 10066 The Twin Towers ( LCS 最长公共子串)
链接:UVa 10192 题意:给定两个字符串.求最长公共子串的长度 思路:这个是最长公共子串的直接应用 #include<stdio.h> #include<string.h> ...
- UVA题目分类
题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics ...
- 算法入门经典大赛 Dynamic Programming
111 - History Grading LCS 103 - Stacking Boxes 最多能叠多少个box DAG最长路 10405 - Longest Common Subsequence ...
- uva 1354 Mobile Computing ——yhx
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABGcAAANuCAYAAAC7f2QuAAAgAElEQVR4nOy9XUhjWbo3vu72RRgkF5
- UVA 10564 Paths through the Hourglass[DP 打印]
UVA - 10564 Paths through the Hourglass 题意: 要求从第一层走到最下面一层,只能往左下或右下走 问有多少条路径之和刚好等于S? 如果有的话,输出字典序最小的路径 ...
- UVA 11404 Palindromic Subsequence[DP LCS 打印]
UVA - 11404 Palindromic Subsequence 题意:一个字符串,删去0个或多个字符,输出字典序最小且最长的回文字符串 不要求路径区间DP都可以做 然而要字典序最小 倒过来求L ...
- UVA&&POJ离散概率与数学期望入门练习[4]
POJ3869 Headshot 题意:给出左轮手枪的子弹序列,打了一枪没子弹,要使下一枪也没子弹概率最大应该rotate还是shoot 条件概率,|00|/(|00|+|01|)和|0|/n谁大的问 ...
随机推荐
- Unity3D游戏制作(四)——Asset Server搭建
本系列文章由 Amazonzx 编写,欢迎转载,转载请注明出处. http://blog.csdn.net/amazonzx/article/details/7980117 Asset Server是 ...
- 在Fedora 20 上安装Mysql并初始化root密码
[root@localhost ~]# yum -y install community-mysql-server #安装数据库 已加载插件:langpacks, refresh-packagekit ...
- cvGet2D的用法
CvScalar s;s = cvGet2D(src, j,i);//获取src图像中坐标为(i,j)的像素点的值s.val[0] 代表src图像BGR中的B通道的值~int nXY = cvGet2 ...
- Hello,World
引用自http://www.cnblogs.com/jbelial/archive/2013/05/08/3067471.html#2676127 题目: 1 public class text { ...
- 模式串匹配,kmp
#include <stdio.h> #include <stdlib.h> #include <string> #include<string.h> ...
- 对xml文件的简单解析
package com.eprobj.demo; import java.io.IOException; import javax.xml.parsers.DocumentBuilder; impor ...
- Spring结合Quartz实现多任务定时调用(转载)
Quartz框架提供了丰富的任务调度支持,比如,在 何时执行何种任务,它是一个开源的由OpenSymphony维护的项目,开发者能够在Java EE,或单独的Java SE应用中使用它.无论是简单的任 ...
- Silverlight 中datagrid控件-- 通过设置数据虚拟化加速显示
定义依赖属性作为datagrid的数据源 protected static readonly DependencyProperty ViewLogsProperty = DependencyPrope ...
- Best Meeting Point
Total Accepted: 701 Total Submissions: 1714 Difficulty: Medium A group of two or more people wants t ...
- MapReduce 程序运行报错 java.lang.ClassNotFoundException解决方法
在创建自定义的Mapper时候,编译正确,但上传到集群执行时出现错误: 11/16/05 22:53:16 INFO mapred.JobClient: Task Id : attempt_20111 ...