hdu 6097 Mindis(几何反演)
来源:互联网 发布:apache转发至python 编辑:程序博客网 时间:2024/06/06 02:31
Mindis
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2598 Accepted Submission(s): 497
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.6568543
5.6568543
5.8945030
6.7359174
5.6568543
5.8945030
6.7359174
根据几何反演,将OP,OQ沿P,Q延长,使OP*OP'=r*r,OQ*OQ'=r*r
△ODP∽△OP'D x=DP/DP'=OP/OD=OD/OP'=|OP|/r
P'Q'/PQ=OP'/OP=(r*r)/(|OP|*|OP|)
(P'D+Q'D)=(PD*x+QD*x)=x*(ans)
ans为所求答案
第一种情况:P'Q'与圆有交点
D是P'Q'与圆的交点
D是P'Q'与圆的交点
P'D'+Q'D'=P'Q'
第二种情况:P'Q'与圆没有交点
D是P'Q'中垂线与圆的交点(因为P,Q是关于O中心对称的,所以P',Q'也与0中心对称,所以P'Q'的中垂线一定过O)
W是P'Q'的中点
P'D'+Q'D=2*P'D=2*√P'Q'^2+(OW-r)^2
#include<cstdio>#include<cstring>#include<stdlib.h>#include<cmath>using namespace std;int r,px,py,qx,qy;int main(){int t;scanf("%d",&t);while(t--){scanf("%d",&r);scanf("%d%d",&px,&py);scanf("%d%d",&qx,&qy);long long int a,b;a=px*px+py*py; //OP,OQb=(px-qx)*(px-qx)+(py-qy)*(py-qy); //PQdouble ans;if(r*r*(4*a-b)<=4*a*a) //p'q'与圆有交点{if(a==0) ans=(double)2*r; //若p,q都在圆心else{double pq=r*r*b*1.0/a; ans=sqrt(pq);}}else{double tmp=r*r+a-r*sqrt(4*a-b);ans=sqrt(tmp)*2;}printf("%.7lf\n",ans);}return 0;}
阅读全文
0 0
- 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 2017 多校联合训练赛6 1002 6097 Mindis 反演变换 计算几何
- HDU 6097 Mindis(圆的反演)
- 多校6 HDU-6097 Mindis 几何数学
- HDU 6097 Mindis(计算几何)
- HDU 6097 Mindis(计算几何)
- (2017多校6)1002/hdu-6097 Mindis(计算几何)
- hud 6097 Mindis(几何)
- hdu 6097 Mindis
- hdu 6097 Mindis (高中数学)
- Leetcode 73. Set Matrix Zeroes
- 问题 C: QAQ & 火星情报局
- API学习Scanner
- linux系统进程管理常用命令
- 模拟模拟交易系统(一)——需求分析
- hdu 6097 Mindis(几何反演)
- eclipse java EE经典绿色版 以及连接远程数据库java代码
- 在tomcat调试成功后在浏览器进入页面的路径
- Mindis(hdu6097)
- HDU Billboard(线段树)
- android Spinner控件设置下拉状态的条目item字体颜色
- 笔试笔记(五)!
- 51nod 1433 0和5
- 你应该知道的25个非常有用的CSS技巧