计蒜客 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的应用)
鉴于我市拥堵的交通状况,市政交管部门经过听证决定在道路两侧安置自动停车收费系统.当车辆驶入车位,系统会通过配有的摄像头拍摄车辆画面,通过识别车牌上的数字.字母序列识别车牌,通过连接车管所车辆信息数据库 ...
随机推荐
- ZooKeeper学习笔记(一)——概述
zookeeper学习笔记(一)--概述 1. 概述 Zookeeper是一个开源的分布式的,为分布式应用提供协调服务的Apache项目.zookeeper从设计模式的角度来理解:是一个基于观察者设计 ...
- 在虚拟机Linux安装Redis
在虚拟机上安装 CentOS 7 安装成功后登录Root用户进入 opt目录,下载Redis. 下载Redis 下载命令: wget http://download.redis.io/releases ...
- JavaScript字符串转数值
JavaScript字符串转数值:方法主要有三种 转换函数.强制类型转换.利用js变量弱类型转换. 1. 转换函数 js提供了parseInt()和parseFloat()两个转换函数.前者把值转换成 ...
- TypeScript编写Vue项目结构解析
使用TypeScript编写Vue项目也已经有了一段时间,笔者在刚刚使用TypeScript时候也是很茫然,不知道从何下手,感觉使用TypeScript写项目感觉很累赘并不像JavaScript那么灵 ...
- Java项目部分总结
一.数据库sql操作: 1.三表查询的时候,最后的条件由于当前字段必须判断是属于哪个表,所以需要注明根据哪个表中的字段进行判断: 并且再在后面加上limit的时候,需要注意先进行添加,避免系统不能识别 ...
- Java集合框架 面试问题整理
简介 java集合类是java.util 包中的重要内容.java集合框架包含了大量集合接口以及这些接口的实现类和操作他们的算法. java集合框架图 主要提供的数据结构 List 又称有序的Coll ...
- jemter csv参数化时注意问题
csv设置 请求参数中引用参数注意点: 查看结果树-请求-http:查看结果,乱码问题解决 1.需要设置下请求体编码 csv设置线程共享模式: 所有线程:测试计划中所有线程,假如说有线程1到线程n ( ...
- 前端cdn库推荐
后端编程人员,有时作功能调试时会用到jquery.layer等的前端库文件,用得较多的我们可以下载下来放到自己的电脑上,有些偶尔使用一次的类库插件就没必要全都下载下来,毕竟不用的类库多了,自己找到它都 ...
- 【转】vsftpd用户登入不进去问题
实在是登陆不上... 我已经加了一个新的用户UID和GID都设置到1000以后 /etc/vsftpd.conf也加了local_enable=yes 以standalone模式运行. 重启服务器后, ...
- ELK-Elasticsearch 基础使用
一.基本概念 1 Node 与 Cluster Elastic 本质上是一个分布式数据库,允许多台服务器协同工作,每台服务器可以运行多个 Elastic 实例.单个 Elastic 实例称为一个节点( ...