UVA 1347(POJ 2677) Tour(双色欧几里德旅行商问题)
Description
John Doe, a skilled pilot, enjoys traveling. While on vacation, he rents a small plane and starts visiting beautiful places. To save money, John must determine the shortest closed tour that connects his destinations. Each destination is represented by a point
in the plane pi = < xi,yi >. John uses the following strategy: he starts from the leftmost point, then he goes strictly left to right to the rightmost point, and then he goes strictly right back to the starting point. It is known that the points have distinct x-coordinates. Write a program that, given a set of n points in the plane, computes the shortest closed tour that connects the points according to John's strategy. Input
The program input is from a text file. Each data set in the file stands for a particular set of points. For each set of points the data set contains the number of points, and the point coordinates in ascending order of the x coordinate. White spaces can occur
freely in input. The input data are correct. Output
For each set of data, your program should print the result to the standard output from the beginning of a line. The tour length, a floating-point number with two fractional digits, represents the result. An input/output sample is in the table below. Here there
are two data sets. The first one contains 3 points specified by their x and y coordinates. The second point, for example, has the x coordinate 2, and the y coordinate 3. The result for each data set is the tour length, (6.47 for the first data set in the given example). Sample Input 3 Sample Output 6.47 算是经典问题了吧。题目大意:给定平面上n个点的坐标(按x的升序), 每点恰有一人经过的最小代价。 #include<iostream> |
版权声明:本文博主原创文章,博客,未经同意不得转载。
UVA 1347(POJ 2677) Tour(双色欧几里德旅行商问题)的更多相关文章
- POJ 2677 Tour
题意:双调欧几里得旅行商问题.算法导论15-1题,从最左边的点严格从左走到右再从右走到左回到起点,所有点都要走且只走一次,求最短路径. 解法:定义dp[i][j]表示从i走到j的双调路径,分为两种情况 ...
- ACM - 动态规划 - UVA 1347 Tour
UVA 1347 Tour 题解 题目大意:有 \(n\) 个点,给出点的 \(x\).\(y\) 坐标.找出一条经过所有点一次的回路,从最左边的点出发,严格向右走,到达最右点再严格向左,回到最左点. ...
- 【玩转单片机系列001】 08接口双色LED显示屏驱动方式探索
前些日子,从淘宝上购得一块08接口的双色LED显示屏(打算做个音乐频谱显示器),捣鼓了好几天,终于搞清楚了其控制原理,在这里做个总结,算是备忘吧. 1.LED显示屏的扫描方式 LED显示屏的扫描方式有 ...
- 完美C++(第5版)(双色)
完美C++(第5版)(双色) 薛正华 沈庚 韦远科 译 ISBN 978-7-121-23198-8 2014年6月出版 定价:148.00元 788页 16开 内容提要 <完美C++(第5版) ...
- HTML5移动开发即学即用(双色) 王志刚 pdf扫描版
HTML5已经广泛应用于各智能移动终端设备上,而且绝大部分技术已经被各种最新版本的测览器所支持:逐一剖析HTML5标准中包含的最新技术,详细介绍了HTML5新标准中提供的各种API,各种各样的应用实例 ...
- 括号序列问题 uva 1626 poj 1141【区间dp】
首先考虑下面的问题:Code[VS] 3657 我们用以下规则定义一个合法的括号序列: (1)空序列是合法的 (2)假如S是一个合法的序列,则 (S) 和[S]都是合法的 (3)假如A 和 B 都是合 ...
- css实现双色饼图
from:wx--前端早读课 首先回想用css画三角形的方法: <div class="triangle"></div> .triangle { displ ...
- UVa 1347 (双线程DP) Tour
题意: 平面上有n个坐标均为正数的点,按照x坐标从小到大一次给出.求一条最短路线,从最左边的点出发到最右边的点,再回到最左边的点.除了第一个和最右一个点其他点恰好只经过一次. 分析: 可以等效为两个人 ...
- UVa 1347 Tour
Tour Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %llu Description Joh ...
随机推荐
- autohotkey excel getfullname (ComObjActive)
- 转 OC温故:类的三大特性(封装,继承,多态)
原文标题:OC学习篇之---类的三大特性(封装,继承,多态) 我们都知道,面向对象程序设计中的类有三大特性:继承,封装,多态,这个也是介绍类的时候,必须提到的话题,那么今天就来看一下OC中类的三大特性 ...
- 7、基于嵌入式Linux的视频采集系统---UVC驱动模型介绍
UVC 即 usb video class.USB协议中,除了通用的软硬件电气接口规范等,还包含了各种各样的Class协议,用来为不同的功能定义各自的标准接口和具体的总线上的数据交互格式和内容.这些C ...
- 细说HTML头部标签
原文 简书原文:https://www.jianshu.com/p/4270b1d1037d 大纲 1.头部标签列表 2.头部标签详解 1.头部标签列表 <!DOCTYPE html> & ...
- C++/Php/Python/Shell 程序按行读取文件或者控制台方法总结。
C++/Php/Python/Shell 程序按行读取文件或者控制台方法总结. 一.总结 C++/Php/Python/Shell 程序按行读取文件或者控制台(php读取标准输入:$fp = fope ...
- thinkphp中如何实现无限级分类?
thinkphp中如何实现无限级分类? 一.总结 1.数据表设计+递归算法 二.php实现无限级分类实例总结 1.数据库数据如下: 2.任务需求:给一个id,求自己和所有父亲. 3.实现代码如下:th ...
- L脚本语言实现文件加解密
L脚本语言中能够对内存对象进行AES加解密.我们能够非常easy地实现文件加解密 #scp #定义一个秘钥字符串 定义:字符串,str1,abcdefg 打开:文件,file1,c:\1.txt 打开 ...
- 接入Erlang控制台的几种方法
在window中调试的时候我们可以通过启动多个cmd窗口运行Erlang节点,在生产环境中我们需要Erlang服务在Centos服务器上后台运行;这就需要在启动的时候添加启动参数detached来脱离 ...
- Hibernate中的配置文件
Hibernate中配置文件 主配置文件 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE h ...
- System.getProperty()获取系统的配置信息(系统变量)
原文地址:http://www.jsjtt.com/java/Javajichu/105.html 此处记录备用. 1. 通过System.getProperty()可以获取系统的配置信息,Syste ...