HDU 6097 Mindis【计算几何】
来源:互联网 发布:单身贵族 知乎 编辑:程序博客网 时间:2024/05/21 19:30
题目来戳呀
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
2017 Multi-University Training Contest - Team 6
题意:
给你一个圆心为o半径为r的圆,p,q两点在园内或圆上,op=oq,找到一个在圆上的点d,使得pd+qd的值最小。输出这个pd+qd。
想法:
预备知识:有一个你不知道就做不出来的知识点:)(用了这个小伙伴的图)
在平面上,给定了半径为r的圆O,对于任意点P,在射线OP上取一点P′,使得OP•OP′=
首先对p点做反演点p1,由反演点定义易得
我们发现PD可以转化成求PD’的值,即PD=PD’×相似比
同理,做出Q的反演点Q’,QD=Q’D×相似比
PD+QD=相似比×(P’D+Q’D),所以接下来的重点就是求P’D+Q’D
连接P’D’.
1.若P’D’与圆有交点,则交点就是D’。
若D不是这个交点,而是圆上其他位置上的点,P’DQ’就会构成三角形,根据三角形的两边之和大于第三边,我们易得只有D是交点时,P’D+Q’D会最短。
2.若P’Q’与圆无交点,则P’D’中垂线与圆的交点是D。
将P’、Q’看作椭圆的两个焦点,P’Q’的中点是原点,P’D’中垂线是短轴
因为在 以 P’ 和 Q’ 为焦点的椭圆上的任意一点到 P’ 和 Q’ 的距离之和 d 相等,为 2a;而在既能在圆上又能在椭圆上的只有椭圆与圆的切点,即中垂线与圆的交点。
#include<bits/stdc++.h>using namespace std;const double eps=1e-8;int main(){ int t; scanf("%d",&t); while(t--) { double r,xp,yp,xq,yq; scanf("%lf%lf%lf%lf%lf",&r,&xp,&yp,&xq,&yq); double op=sqrt(pow(xp,2)+pow(yp,2)); if(fabs(op)<eps)///p q两个点无限相交的时候 { printf("%.7f\n",2*r); } else { double ans; double scale=r*r/(op*op);///相似比 double xp1=xp*scale,yp1=yp*scale,xq1=xq*scale,yq1=yq*scale; double midx=(xp1+xq1)/2,midy=(yp1+yq1)/2; double mid_o=sqrt(pow(midx,2)+pow(midy,2)); if(mid_o<=r)///直线与圆相交 D是交点 { double p1q1=sqrt(pow(xp1-xq1,2)+pow(yp1-yq1,2)); ans=d1*op/r; } else///切点在之外 D就是中垂线与圆的交点 { double k=r/mid_o; double newmidx=k*midx,newmidy=k*midy; ans=2*sqrt(pow(newmidx-xp,2)+pow(newmidy-yp,2)); } printf("%.7f\n",ans); } } return 0;}
ps:呜啊 这个真的就是纯几何题了吧QAQ 之前没接触过反演,看到有人说初中知识,怀疑我的初中真的存在过吗QAQ
- HDU 6097 Mindis【计算几何】
- HDU 6097 Mindis(计算几何)
- HDU 6097 Mindis【计算几何+反演点】
- HDU 6097 Mindis(计算几何)
- hdu 6097 Mindis(几何)
- HDU 6097 Mindis【几何】
- HDU 6097 Mindis 几何
- (2017多校6)1002/hdu-6097 Mindis(计算几何)
- HDU 6097 Mindis(几何)
- hdu 6097 Mindis(几何反演)
- 多校6 HDU-6097 Mindis 几何数学
- 2017多校六 1002题 hdu 6097 Mindis 相似三角形 计算几何
- HDU 2017 多校联合训练赛6 1002 6097 Mindis 反演变换 计算几何
- hdu6097—Mindis(计算几何)
- hud 6097 Mindis(几何)
- hdu 6097 Mindis
- hdu 6097 Mindis (高中数学)
- Mindis HDU-6097
- 如何在神箭手上快速开发爬虫——第四课 如何爬取分页数据【蘑菇街商品评论】
- Kali Linux WPScan更新到2.9.3
- linux下串口相关控制
- plsql直接安装
- kafka集群操作指南
- HDU 6097 Mindis【计算几何】
- 【java自然语言处理】缩句
- linux常用指令
- js 中Array.concat()实现方法
- 【error】LINK1123: failure during conversion to COFF: file invalid or corrupt
- 微信小程序开发效果:animation心跳动画
- 优秀人才为何要离开大型技术公司
- HDU
- Android: 解决软键盘弹出覆盖界面问题