HDU 6097 Mindis 几何
来源:互联网 发布:法修史丹比特 知乎 编辑:程序博客网 时间:2024/06/07 08:36
题目链接:HDU 6097
Mindis
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 3168 Accepted Submission(s): 644
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
题意:
一个圆和2个点PQ,PQ在园内并且OP=OQ,然后找圆上一点D使得PD+QD最小。
题目分析:
找PQ的反演点然后巧妙的构造相似三角形,很巧妙的解决了精度和时间问题。给“优秀的黄金分割”卡过的dalao们递茶~
//// main.cpp// HDU6097 Mindis//// Created by teddywang on 2017/8/13.// Copyright © 2017年 teddywang. All rights reserved.//#include <iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>using namespace std;double xp,yp,xq,yq,r,R;double x,y,x2,y2;double eps=1e-8;int T;struct point{ double x,y; point(){ x=0; y=0; } point(double X,double Y){ x=X; y=Y; } };point p,q;point zero=point(0.0,0.0);double dis(point a,point b){ return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));}point shucheng(point a,double b){ point c=point(a.x*b,a.y*b); return c;}double chacheng(point a,point b){ double buf=(a.x*b.y)-(a.y*b.x); if(buf>eps) return buf; else return 0-buf;}bool judge_eq(point a,point b){ if(a.x==b.x&&a.y==b.y) return true; else return false;}bool judge2(point a,point b){ double buf=r*r/dis(zero,a)/dis(zero,b); point c=shucheng(a,buf); point d=shucheng(b,buf); double s=chacheng(c,d)/dis(c,d); if(s-r>eps) return false; else return true;}int main(){ scanf("%d",&T); double ans; while(T--) { scanf("%lf",&r); scanf("%lf%lf",&p.x,&p.y); scanf("%lf%lf",&q.x,&q.y); if(judge_eq(p, q)) { ans=(r-dis(zero,p))*2; } else { if(judge2(p,q)) { double buf=r*r/dis(zero,p)/dis(zero,p); point p1=shucheng(p,buf); point q1=shucheng(q,buf); ans=dis(p1,q1)*dis(p,zero)/r; } else { point mid=point((p.x+q.x)/2.00,(p.y+q.y)/2.00); double buf=r/dis(zero,mid); mid=shucheng(mid,buf); ans=dis(mid,p)+dis(mid,q); } } printf("%.7f\n",ans); }}
阅读全文
0 0
- hdu 6097 Mindis(几何)
- HDU 6097 Mindis【几何】
- HDU 6097 Mindis 几何
- HDU 6097 Mindis(几何)
- hdu 6097 Mindis(几何反演)
- HDU 6097 Mindis【计算几何】
- 多校6 HDU-6097 Mindis 几何数学
- HDU 6097 Mindis(计算几何)
- HDU 6097 Mindis【计算几何+反演点】
- HDU 6097 Mindis(计算几何)
- (2017多校6)1002/hdu-6097 Mindis(计算几何)
- hud 6097 Mindis(几何)
- hdu 6097 Mindis
- hdu 6097 Mindis (高中数学)
- Mindis HDU-6097
- HDU 6097 Mindis
- HDU 6097 Mindis(反演)
- HDU 6097 Mindis
- 预解析
- 中国剩余定理讲解
- .NET/C#调用webservice的坑
- 关于web开发的地址的问题
- 概率题 数学 智力
- HDU 6097 Mindis 几何
- 金蝶K3序时簿页面增加物料即时库存显示功能
- MySql 报ERROR 1292 (22007) 故障
- Hive桶表的操作
- 1565植物大战僵尸
- hdu3410 Passing the Message 单调栈
- 分数拆分(C++)
- 脚本处理大数据文件
- .ascx用户控件