博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdu 3272 Mission Impossible
阅读量:4311 次
发布时间:2019-06-06

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

Mission Impossible

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 414    Accepted Submission(s): 178

Problem Description
There are A, B, C, D four kinds of resources, A can be obtained at any point in the X-axis. B can be obtained at any point in the Y-axis. C and D each will only be able to achieve at a certain point. Giving the coordinates of C and D, the coordinates of your current location. Find the shortest path to obtain the four kinds of resources and go back.
 

 

Input
The first line contains the number T of test cases(T<=150). Each of the following T lines consists of six integers cx, cy, dx, dy, hx and hy. (cx, cy) is the coordinates of resource C, (dx, dy) is the coordinates of resource D, (hx, hy) is the coordinates of your current location.
All the numbers of the input are in the range [-1000, 1000].
 

 

Output
Your program should produce a single line for each test case containing the length of the shortest path. The answers should be rounded to two digits after the decimal point.
 

 

Sample Input
3
1 1 2 2 3 3
1 1 -1 -1 -1 -1
1 -1 1 1 -1 1
 

 

Sample Output
8.49
5.66
6.83
 

 

Author
hanshuai
 
 
题意:给你C,D两点的坐标,再给起点H的坐标,A在x轴上任意位置,B在y轴上任意位置,要求从起点出发经过A,B,C,D四点后回到起点的最小距离。
 
有点麻烦的一道题,也是照着别人博客写的,每种情况都要分析。
 
用到了镜面定理:

当坐标在轴同一侧时,对其中一个点的该坐标取反,得到的新点求距离就是镜面反射的距离。

如果在不同侧,就直接求距离

 

附上代码:

 

1 #include 
2 #include
3 #include
4 #include
5 using namespace std; 6 7 struct Point 8 { 9 double x,y; 10 }h,p[3]; 11 12 double mins(double a,double b) 13 { 14 return a

 

转载于:https://www.cnblogs.com/pshw/p/5719077.html

你可能感兴趣的文章
安装IIS
查看>>
动态加载JS(转)
查看>>
SWUST OJ(961)
查看>>
js换空格为别的元素
查看>>
Recommendation Systems
查看>>
shell脚本 inotify + rsync 同步脚本
查看>>
maven pom 引入本地jar包
查看>>
QVT之The Relations Language(Part 二)
查看>>
python--dict和set类型--4
查看>>
快速实现Magento多语言的设置和产品数据的多语言方法
查看>>
python操作数据库
查看>>
Django的ORM基本操作补充一对多
查看>>
A - Oil Deposits(搜索)
查看>>
E - Phone List(字典序,string类型使用)
查看>>
自定义SeekBar三步
查看>>
"Coding Interview Guide" -- 设计一个有getMin功能的栈
查看>>
Java基础知识强化之多线程笔记06:Lock接口 (区别于Synchronized块)
查看>>
PHP笔记09:PHP之 MVC理解
查看>>
Android(java)学习笔记20:UDP协议发送数据
查看>>
stata学习笔记(五):描述性统计分析
查看>>