Mindis

Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 2787    Accepted Submission(s): 555
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 makes PD+QD minimum.
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

 
Output
For each case output one line denotes the answer.
The answer will be checked correct if its absolute or relative error doesn't exceed 10−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.
 
Sample Input
4
4
4 0
0 4
4
0 3
3 0
4
0 2
2 0
4
0 1
1 0
 
Sample Output
5.6568543
5.6568543
5.8945030
6.7359174
 
Source
Recommend
liuyiding   |   We have carefully selected several similar problems for you:  6119 6118 6117 6116 6115 
 
以下转自:http://blog.csdn.net/kkkkahlua/article/details/77074409

题意:

圆心 O 坐标(0, 0), 给定两点 P, Q(不在圆外),满足 PO = QO,

要在圆上找一点 D,使得 PD + QD 取到最小值。

官方题解:

做P点关于圆的反演点P',OPD与ODP'相似,相似比是|OP| : r。

Q点同理。

极小化PD+QD可以转化为极小化P'D+Q'D。

当P'Q'与圆有交点时,答案为两点距离,否则最优值在中垂线上取到。

时间复杂度 O(1)O(1)

补充说明:

反演:

设在平面内给定一点O和常数k(k不等于零),对于平面内任意一点A,确定A′,使A′在直线OA上一点,并且有向线段OA与OA′满足OA·OA′=k,我们称这种变换是以O为的反演中心,以k为反演幂的反演变换,简称反演。——百度百科

在这里,k 即为圆半径 r ^ 2,因此,相似就是显然的了。

当 P'Q' 与圆有交点时:

不妨设交点为 O',若 D 不为 O',则 P'D + Q'D >  P'Q'(三角形两边之和大于第三边);当且仅当 D 取 O' 时,P'Q + Q'D 取到最小值,即为 P'Q'。

当 P'Q' 与圆无交点时:

不妨将 P' 与 Q' 看成椭圆的两个焦点,当椭圆慢慢变大时,第一个碰到的圆上的点 D 即为使得 P'D + Q'D 最小的点;画个图就很显然了,第一个碰到的点即为 PQ 的中垂线与圆的交点。

至于判断有 P'Q' 与圆有没有交点,就是圆心到直线的距离与半径比较,又因为此处 P'O=Q'O,所以只需要比较 P'Q' 的中点到圆心的距离和半径的大小。

注意点:

1. 注意 PO = QO = 0 的情况

2. 尽量用比例而不是角度进行计算

 
这题精度很是问题
#include <iostream>
#include<bits/stdc++.h>
using namespace std; const double eps=1e-;
int t;
double R,px,py,qx,qy;
int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%lf%lf%lf%lf%lf",&R,&px,&py,&qx,&qy);
if (px== && py==) {printf("%.7lf\n",*R);continue;}
double r=sqrt(pow(px,)+pow(py,));
double k=R*R/(r*r); //不是相似比
double ppx=px*k,ppy=py*k,qqx=qx*k,qqy=qy*k;
//printf("%.2lf %.2lf\n",ppx,ppy);
double midx=(ppx+qqx)/,midy=(ppy+qqy)/;
double dis=sqrt(pow(midx,)+pow(midy,) );
//printf("%.7lf\n",dis);
if (dis<=R)
{
// double op2=sqrt(pow(ppx,2)+pow(ppy,2));
printf("%.7lf\n",sqrt(pow(ppx-qqx,)+pow(ppy-qqy,))*r/R); } else
{
double mx=midx/dis*R; double my=midy/dis*R;
printf("%.7lf\n",*sqrt(pow(mx-px,)+pow(my-py,)) );
}
}
return ;
}

hdu 6097 Mindis(数学几何,圆心的反演点)的更多相关文章

  1. 2017多校第6场 HDU 6097 Mindis 计算几何,圆的反演

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6097 题意:有一个圆心在原点的圆,给定圆的半径,给定P.Q两点坐标(PO=QO,P.Q不在圆外),取圆 ...

  2. 2017ACM暑期多校联合训练 - Team 6 1002 HDU 6097 Mindis (数学)

    题目链接 Problem Description The center coordinate of the circle C is O, the coordinate of O is (0,0) , ...

  3. HDU 6097 Mindis (计算几何)

    题意:给一个圆C和圆心O,P.Q是圆上或圆内到圆心距离相等的两个点,在圆上取一点D,求|PD| + |QD|的最小值 析:首先这个题是可以用三分过的,不过也太,.... 官方题解: 很不幸不总是中垂线 ...

  4. hdu 1577 WisKey的眼神 (数学几何)

    WisKey的眼神 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total S ...

  5. hdu 1115 Lifting the Stone (数学几何)

    Lifting the Stone Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

  6. hdu 5605 geometry(几何,数学)

    Problem Description There is a point P at coordinate (x,y). A line goes through the point, and inter ...

  7. HDU 5673 Robot 数学

    Robot 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5673 Description There is a robot on the origi ...

  8. 2019 年百度之星·程序设计大赛 - 初赛一 C. HDU 6670 Mindis 离散化+dijkstra

    题目链接 :http://acm.hdu.edu.cn/showproblem.php?pid=6670 Mindis Time Limit: 4000/2000 MS (Java/Others) M ...

  9. ACM: FZU 2110 Star - 数学几何 - 水题

     FZU 2110  Star Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u  Pr ...

随机推荐

  1. Spring-1-F Dice(HDU 5012)解题报告及测试数据

    Dice Time Limit:1000MS     Memory Limit:65536KB Description There are 2 special dices on the table. ...

  2. 联想(Lenovo)小新310经典版进bios方法

    1,找到novo按钮. 2,在关机的状态下桶一下小孔,不用任何操作,电脑进入bios选择界面.

  3. eclipse中Web Deployment Assembly与build path作用

    java Build path是编译路径设置,主要用来设置源代码的编译路径默认是default output folder Web Deployment Assembly是eclipse中的发布路径设 ...

  4. docker基本用法和命令

    1.安装docker 检查有没有curl which curl 如果没有用以下命令可安装:sudo apt-get install curl 通过官方提供的脚本安装最新docker curl -sSL ...

  5. Django学习笔记之Models与ORM操作

    一.ORM增加 from django.db import models class Publisher(models.Model): name = models.CharField(max_leng ...

  6. CSS3 简介

    CSS3 简介 对CSS3已完全向后兼容,所以你就不必改变现有的设计.浏览器将永远支持CSS2. CSS3被拆分为"模块".旧规范已拆分成小块,还增加了新的. 一些最重要CSS3模 ...

  7. 20145329《Java程序设计》第四周学习总结

    教材学习内容总结 封装.继承.多态 封装:封装类私有数据,让用户无法直接存取. 继承: 定义:避免多个类间重复定义共同行为,就是相同的代码提升为父类,java中只能继承一个父类.用继承的方式编写代码可 ...

  8. 2017杭电ACM集训队单人排位赛 - 6

    2017杭电ACM集训队单人排位赛 - 6 排名 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 59 1 X X 1 1 X X 0 1 ...

  9. linux下nano中复制粘贴剪切的快捷键是什么

    答: 1.复制:alt+6 2.剪切:ctrl+k 3.粘贴:ctrl+u 4.自由剪切: ctrl+6指定起始剪切位置,按上下左右键来选中内容,然后按下ctrl+k即可自由剪切 5.撤销: alt+ ...

  10. Django Nginx配置

    1.安装uwsgi.flup.djangowget http://www.saddi.com/software/flup/dist/flup-1.0.2.tar.gz 2.项目创建和配置2.1.创建项 ...