Hdu6097 Mindis(2017多校第6场)
来源:互联网 发布:linux iptables pat 编辑:程序博客网 时间:2024/05/21 11:04
Mindis
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1056 Accepted Submission(s): 112
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
————————————————————————————————
题目的意思是给出一个圆,和圆内(上)距圆心的相等的两个点,求在圆上取一个点使得到这两个点的距离和最小
思路:数学推导出公式计算,注意卡精度(队友真是太强了)
#include <iostream>#include <cstdio>#include <cstring>#include <map>#include <set>#include <string>#include <cmath>#include <algorithm>#include <vector>#include <bitset>#include <stack>#include <queue>#include <functional>using namespace std;int R;int x[3],y[3];double ddabs(double xx){ if(xx < 0) return -xx; return xx;}int main(){ int t; scanf("%d",&t); while(t--) { scanf("%d",&R); for(int i=1;i<=2;i++) scanf("%d%d",&x[i],&y[i]); int rr=(x[1]*x[1])+(y[1]*y[1]); if(rr == 0) { printf("%.7f\n", R * 2.0); continue; } int dd=(x[1]-x[2])*(x[1]-x[2])+(y[1]-y[2])*(y[1]-y[2]); double o=acos((2.0*rr-dd)/rr/2.0); double a,b,ans1; double r=sqrt(1.0 * rr); a=1.0*(R*R+rr)*cos(o/2.0)/(2.0*R*r); b=a*a-(1.0+(2.0*rr-dd)/rr/2.0)/2.0; if(ddabs(b) < 1e-8) b = 0; ans1=a+sqrt(b); double t; if(ans1 > 1 || ans1 < cos(o)) { t = o/2.0; } else { t=acos(ans1)*2.0; t=(t+o)/2.0; } double x=sqrt(R*R+rr-2.0*R*r*cos(t)); double y=sqrt(R*R+rr-2.0*R*r*cos(o-t)); printf("%.7f\n",x+y); } return 0;}
阅读全文
1 0
- Hdu6097 Mindis(2017多校第6场)
- Mindis(hdu6097)
- 多校 HDU6097 Mindis (几何)
- HDU6097-Mindis
- hdu6097 Mindis 2017多校第六场1002 圆的反演
- hdu6097—Mindis(计算几何)
- hdu6097 Mindis【圆的反演】
- 2017 多校训练第六场 HDU 6097 Mindis
- (2017多校6)1002/hdu-6097 Mindis(计算几何)
- HDU6097(数学题。。。。)
- HDU-2017 多校训练赛6-1002-Mindis
- HDU 6097 Mindis(几何)
- hud 6097 Mindis(几何)
- Hdu6098 Inversion(2017多校第6场)
- Hdu6103 Kirinriki(2017多校第6场)
- Hdu6106 Classes(2017多校第6场)
- Hdu6105 Gameia(2017多校第6场)
- HDU 2017 多校联合训练赛6 1002 6097 Mindis 反演变换 计算几何
- java:什么是抽象类,以及抽象类的作用和用法(abstract)
- ELF文件格式分析
- RandomForest、GBDT和XGBOOST
- stm32与串口通信
- ZOJ -1008 -Gnome Tetravex
- Hdu6097 Mindis(2017多校第6场)
- html 不规则table表格
- 嵌入式每日学习心得2017.08.10
- spring mvc基础篇(十):注解配置入门
- Mongodb 备份 还原 导出 导入 等批量操作
- 如何将Eclipse中的项目迁移到Android Studio 中
- 2. Python入门:字符串和变量
- 分布式和集群的区别 以及理解
- 使用BigDecimal进行精确运算