HDU 6097 Mindis
来源:互联网 发布:php修复00截断的版本 编辑:程序博客网 时间:2024/06/05 23:25
Mindis
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1525 Accepted Submission(s): 239
Special Judge
Problem Description
The center coordinate of the circle C is O, the coordinate of O is (0,0) , and the radius is r.
P and Q are two points not outside the circle, and PO = QO.
You need to find a point D on the circle, which makesPD+QD minimum.
Output minimum distance sum.
P and Q are two points not outside the circle, and PO = QO.
You need to find a point D on the circle, which makes
Output minimum distance sum.
Input
The first line of the input gives the number of test cases T; T test cases follow.
Each case begins with one line with r : the radius of the circle C.
Next two line each line contains two integers x , y denotes the coordinate of P and Q.
Limits
T≤500000
−100≤x,y≤100
1≤r≤100
Each case begins with one line with r : the radius of the circle C.
Next two line each line contains two integers x , y denotes the coordinate of P and Q.
Limits
Output
For each case output one line denotes the answer.
The answer will be checked correct if its absolute or relative error doesn't exceed10−6 .
Formally, let your answer be a, and the jury's answer be b. Your answer is considered correct if|a−b|max(1,b)≤10−6 .
The answer will be checked correct if its absolute or relative error doesn't exceed
Formally, let your answer be a, and the jury's answer be b. Your answer is considered correct if
Sample Input
444 00 440 33 040 22 040 11 0
Sample Output
5.65685435.65685435.89450306.7359174
Source
2017 Multi-University Training Contest - Team 6
题意:
在平面直角坐标系中,一个圆的圆心在原点
在该圆上或圆内给出两点P,Q,使得两点到圆心距离相等 PO = QO
现在,在圆上找出一点D,使得PD+QD的值最小
题解:
做P,Q反演点P',Q'
连接P'Q',做中垂线
(以P‘Q’为焦点做椭圆,存在椭圆的几何性质,椭圆上任一点到两焦点之和距离相等)
中垂线与圆的交点即为所求D点
再根据相似三角形的几何性质,求出比例关系 对应相乘即可
(思路参考kkkkahlua 谢谢哥)
#include<stdio.h>#include<string.h>#include<algorithm>#include<math.h>#define ll long longusing namespace std;const double eps = 1e-8;int main(){int t;scanf("%d",&t);while(t--){double r,x1,y1,x2,y2,ans;scanf("%lf %lf %lf %lf %lf",&r,&x1,&y1,&x2,&y2);double d0 = sqrt(x1 * x1 + y1 * y1);if(fabs(d0) < eps){printf("%.7lf\n",2 * r);continue;}//利用相似三角形比例关系证明 double k = r * r / (d0 * d0);double px = x1 * k,py = y1 * k;double qx = x2 * k,qy = y2 * k;double midx = (px + qx) / 2;double midy = (py + qy) / 2;double d = sqrt(midx * midx + midy * midy);if(d <= r){//与圆有交点 利用P’Q’与O的距离和半径进行比较 double distance = sqrt(pow(px - qx,2) + pow(py - qy,2));ans = distance * d0 / r;}else{double sumx = midx * (r / d);double sumy = midy * (r / d);ans = 2 * sqrt(pow(sumx - x1,2) + pow(sumy - y1,2));}printf("%.7lf\n",ans);}return 0;}
阅读全文
0 0
- hdu 6097 Mindis
- hdu 6097 Mindis (高中数学)
- Mindis HDU-6097
- HDU 6097 Mindis
- HDU 6097 Mindis(反演)
- hdu 6097 Mindis(几何)
- HDU 6097 Mindis
- HDU 6097 Mindis
- HDU 6097 Mindis【几何】
- HDU 6097 Mindis
- HDU 6097 Mindis
- HDU 6097 Mindis
- HDU 6097 Mindis 几何
- HDU 6097 Mindis(几何)
- hdu 6097 Mindis (反演点)
- hdu 6097 Mindis(几何反演)
- HDU 6097 Mindis【计算几何】
- HDU 6097 Mindis 代数方法
- Java反射机制知识总结
- 算法题目---圆圈中最后剩下的数字
- java.security.cert.CertificateException: No name matching api.weibo.com found;取消验证
- Git学习笔记
- Linux 的启动流程
- HDU 6097 Mindis
- Linux下ffmpeg交叉编译
- 成为Java顶尖程序员 ,看这11本书就够了
- 2017 Android GitHub常用热门开源框架汇总
- 统计自然语言处理1-----绪论(二)
- SpringBoot入门(三)Controller的使用
- java正则表达式
- java动态代理
- 新手 使用eclipse springMVC xml 不提示问题解决方案