博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
poj-2677 动态规划、双调欧几里得旅行商
阅读量:7099 次
发布时间:2019-06-28

本文共 1731 字,大约阅读时间需要 5 分钟。

Tour
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 2699   Accepted: 1193

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

31 12 33 141 12 33 14 2

Sample Output

6.477.89

微笑题目大意:给出一些点的坐标,顺序为从左到右。飞行员小明要飞一段旅程。

微笑分析:先略。

你可能感兴趣的文章
vm12 安装ubuntu15.10详细图文教程 虚拟机安装ubuntu安装 ubuntu更新软件 ubuntu一直卡在下载语言怎么办?...
查看>>
你还有好多未完成的梦,怎么能够停下脚步
查看>>
php自动读取文件夹下所有图片
查看>>
js 获取checkbox选中项目
查看>>
VC6使用技巧
查看>>
文本报告生成工具gawk
查看>>
pdf文档如何转换成txt文档
查看>>
面向对象(OO)设计原则
查看>>
Python 字典的使用
查看>>
DELL32位诊断工具PEDIAGS使用
查看>>
产品经理的麻烦地图
查看>>
如何通过刷百度指数来提高网站的权重
查看>>
轻量级HTTP服务器Nginx(常用配置实例)
查看>>
FAT32文件系统
查看>>
Mysql存储过程分析
查看>>
文件系统权限 -- 学习笔记
查看>>
windows2008域上装oracle10gR2
查看>>
mac终端命令大全介绍(稍加整理)
查看>>
深度技术 GHOST XP SP3 快速装机专业版 V2013.04 [DVD版本]
查看>>
CloudStack部署篇一 平台安装
查看>>