计蒜客 39270.Angel's Journey-简单的计算几何 ((The 2019 ACM-ICPC China Shannxi Provincial Programming Contest C.) 2019ICPC西安邀请赛现场赛重现赛
“Miyane!” This day Hana asks Miyako for help again. Hana plays the part of angel on the stage show of the cultural festival, and she is going to look for her human friend, Hinata. So she must find the shortest path to Hinata’s house.
The area where angels live is a circle, and Hana lives at the bottom of this circle. That means if the coordinates of circle’s center is (rx, ry)(rx,ry) and its radius is rr, Hana will live at (rx, ry - r)(rx,ry−r).
Apparently, there are many difficulties in this journey. The area which is located both outside the circle and below the line y = ryy=ry is the sea, so Hana cannot pass this area. And the area inside the circle is the holy land of angels, Hana cannot pass this area neither.
However, Miyako cannot calculate the length of the shortest path either. For the loveliest Hana in the world, please help her solve this problem!
Input
Each test file contains several test cases. In each test file:
The first line contains a single integer T(1 \le T \le 500)T(1≤T≤500) which is the number of test cases.
Each test case contains only one line with five integers: the coordinates of center rxrx 、 ryry, the radius rr, thecoordinates of Hinata’s house xx 、yy. The test data guarantees that y > ryy>ry and (x, y)(x,y) is out of the circle. (-10^2 \le rx,ry,x,y \le 10^2,0 < r \le 10^2)(−102≤rx,ry,x,y≤102,0<r≤102).
Output
For each test case, you should print one line with your answer (please keep 44 decimal places).
样例输入复制
2
1 1 1 2 2
1 1 1 1 3
样例输出复制
2.5708
3.8264
题意就是给一个圆,求从圆的最底下,到圆中线上面的圆外一个位置的最短距离。
比赛时,板子套歪了,发现直接手算就可以。
代码:
//C-简单的计算几何
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+;
const double PI=acos(-1.0); int main()
{
int t;
scanf("%d",&t);
while(t--){
double rx,ry,r,x,y;
scanf("%lf%lf%lf%lf%lf",&rx,&ry,&r,&x,&y);
double length=0.0;
if((x<=rx-r)||(x>=rx+r)){
if(x<=rx-r){
length+=sqrt((x-(rx-r))*(x-(rx-r))+(y-ry)*(y-ry));
length+=0.5*PI*r;
}
else{
length+=sqrt((x-(rx+r))*(x-(rx+r))+(y-ry)*(y-ry));
length+=0.5*PI*r;
}
}
else{
double d=sqrt((x-rx)*(x-rx)+(y-ry)*(y-ry));
double jiao;
if(x!=rx){
double cosr=abs(x-rx)/d;
jiao=acos(cosr)-acos(r/d);
}
else{
jiao=0.5*PI-acos(r/d);
}
jiao+=0.5*PI;
length+=jiao*r;
length+=sqrt(d*d-r*r);
}
printf("%.4f\n",length);
}
}
计蒜客 39270.Angel's Journey-简单的计算几何 ((The 2019 ACM-ICPC China Shannxi Provincial Programming Contest C.) 2019ICPC西安邀请赛现场赛重现赛的更多相关文章
- 计蒜客 39280.Travel-二分+最短路dijkstra-二分过程中保存结果,因为二分完最后的不一定是结果 (The 2019 ACM-ICPC China Shannxi Provincial Programming Contest M.) 2019ICPC西安邀请赛现场赛重现赛
Travel There are nn planets in the MOT galaxy, and each planet has a unique number from 1 \sim n1∼n. ...
- 计蒜客 39279.Swap-打表找规律 (The 2019 ACM-ICPC China Shannxi Provincial Programming Contest L.) 2019ICPC西安邀请赛现场赛重现赛
Swap There is a sequence of numbers of length nn, and each number in the sequence is different. Ther ...
- 计蒜客 39272.Tree-树链剖分(点权)+带修改区间异或和 (The 2019 ACM-ICPC China Shannxi Provincial Programming Contest E.) 2019ICPC西安邀请赛现场赛重现赛
Tree Ming and Hong are playing a simple game called nim game. They have nn piles of stones numbered ...
- 计蒜客 39268.Tasks-签到 (The 2019 ACM-ICPC China Shannxi Provincial Programming Contest A.) 2019ICPC西安邀请赛现场赛重现赛
Tasks It's too late now, but you still have too much work to do. There are nn tasks on your list. Th ...
- 计蒜客-跳跃游戏二 (简单dp)
题目链接:https://nanti.jisuanke.com/t/20 跳跃游戏二 给定一个非负整数数组,假定你的初始 ...
- 计蒜客 41391.query-二维偏序+树状数组(预处理出来满足情况的gcd) (The Preliminary Contest for ICPC Asia Xuzhou 2019 I.) 2019年徐州网络赛)
query Given a permutation pp of length nn, you are asked to answer mm queries, each query can be rep ...
- 计蒜客 31434 - 广场车神 - [DP+前缀和]
题目链接:https://nanti.jisuanke.com/t/31434 小 D 是一位著名的车手,他热衷于在广场上飙车.每年儿童节过后,小 D 都会在广场上举行一场别样的车技大赛. 小 D 所 ...
- 2019计蒜客信息学提高组赛前膜你赛 #2(TooYoung,TooSimple,Sometimes Naive
计蒜客\(2019CSP\)比赛第二场 巧妙爆零这场比赛(我连背包都不会了\(QWQ\) \(T1\) \(Too\) \(Young\) 大学选课真的是一件很苦恼的事呢! \(Marco\):&qu ...
- 计蒜客 作弊揭发者(string的应用)
鉴于我市拥堵的交通状况,市政交管部门经过听证决定在道路两侧安置自动停车收费系统.当车辆驶入车位,系统会通过配有的摄像头拍摄车辆画面,通过识别车牌上的数字.字母序列识别车牌,通过连接车管所车辆信息数据库 ...
随机推荐
- HttpClient参观记:.net core 2.2 对HttpClient到底做了神马
.net core 于 10月17日发布了 ASP.NET Core 2.2.0 -preview3,在这个版本中,我看到了一个很让我惊喜的新特性:HTTP Client Performance Im ...
- Java abstract 理解和学习
/** * <html> * <body> * <P> Copyright JasonInternational Since 1994 https://github ...
- C#-Windows服务创建和运行
Windows服务创建和运行 适用场景: ASP.Net通常是一个无状态的提供程序,不支持持续运行代码或者定时执行某段代码,所以我们需要构建自己的Windows服务来运行那些定时任务. 项目中需 ...
- 在docker容器上如何实现代码的版本管理
之前在一台centos7的虚拟机上部署了docker并运行了三个容器给开发写代码用,写代码肯定会涉及到版本控制管理. 开始建议是开发在容器中写代码,然后通过docker commit的方式将其保存为i ...
- printk打印级别
默认级别 # cat /proc/sys/kernel/printk 4 4 1 7 分别是:控制台日志级别.默认的消息日志级别.最低的控制台日志级别和默认的控制台日志级别 举例 # echo 0 & ...
- sql 语句中关于 not in 和 null 的问题简单解析
理解这个问题,只需要记住一个逻辑: null 和任何值比较运算都返回的 false Ex: SQL01: SELECT * FROM userinfo WHERE age NOT IN() SQL01 ...
- Flask--登录验证(多个装饰器)
登录验证(多个装饰器) from flask import Flask,url_for,session,render_template import functools app = Flask(__n ...
- MavenWrapper替代Maven
1. 说明 jdk8已经安装成功 Maven已经安装成功 参见Maven Wrapper 2. Maven初始化项目 注:初次执行,Maven会下载很多jar,需等待几分钟 mvn archetype ...
- Springboot项目中Pom.xml报错
摘要:使用idea,两次在maven上浪费时间,第一次不知道怎么就解决了,第二次记录一下解决办法 参考博客地址: https://blog.csdn.net/u013129944/article/de ...
- $(...) is null
删冲突插件,jquery作为基础库,当然是没有理由被删了.这个方法最直接了. (2)将jquery的$方法改名,具体改名方法如下: jQuery.noConflict();//将变量$的控制权让渡给给 ...