German Collegiate Programming Contest 2018 B. Battle Royale
Battle Royale games are the current trend in video games and Gamers Concealed Punching Circles (GCPC) is the most popular game of them all. The game takes place in an area that, for the sake of simplicity, can be thought of as a two-dimensional plane. Movement and positioning are a substantial part of the gameplay, but getting to a desired location can be dangerous. You are confident in your ability to handle the other players, however, while you are walking to your destination, there are two hazards posed by the game itself:
- The game zone is bounded by a blue circle. Outside of this circle, there is a deadly force field that would instantly take you out of the game.
- Inside the game zone, there is a red circle where you are exposed to artillery strikes. This circle is also too risky to enter.
You want to move from one spot on the map to another, but the direct path to your destination is blocked by the red circle, so you need to find a way around it. Can you find the shortest path that avoids all hazards by never leaving the blue or entering the red circle? Touching the boundaries of the circles is fine, as long as you do not cross them.
Input Format
The input consists of:
- one line with two integers x_cxc, y_cyc specifying your current location;
- one line with two integers x_dxd, y_dyd specifying your destination;
- one line with three integers x_b, y_b, r_bxb,yb,rb specifying the center and radius of the blue circle;
- one line with three integers x_rxr , y_ryr , r_rrr specifying the center and radius of the red circle.
All coordinates have an absolute value of at most 1 0001000, and 1 \le r_b, r_r \le 1 0001≤rb,rr≤1000. The red circle is strictly inside the blue circle. Your current location and destination are strictly inside the blue circle and strictly outside of the red circle, and the direct path between them is blocked by the red circle.
Output Format
Output the length of the shortest path that does not leave the blue or enter the red circle. The output must be accurate up to a relative or absolute error (whichever is lower) of 10^{-7}10−7.
本题答案不唯一,符合要求的答案均正确
样例输入
0 0
10 0
0 0 1000
5 0 2
样例输出
10.8112187742
题目来源
German Collegiate Programming Contest 2018
红色部分为所求的
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cmath>
typedef long long ll;
#define lowbit(x) (x&(-x))
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
using namespace std;
#define pi acos(-1)
double sx,sy,ex,ey;
double rx,ry,rr;
double mx,my,mr;
double dist(double x1,double x2,double y1,double y2)
{
return sqrt(pow(x1-x2,)+pow(y1-y2,));
}//两点间的距离
int main()
{
scanf("%lf%lf%lf%lf",&sx,&sy,&ex,&ey);
scanf("%lf%lf%lf",&mx,&my,&mr);
scanf("%lf%lf%lf",&rx,&ry,&rr);
double a=dist(sx,rx,sy,ry);
double b=sqrt(pow(a,)-pow(rr,));//切线
double c=dist(ex,rx,ey,ry);
double d=sqrt(pow(c,)-pow(rr,));//切线
double e=dist(sx,ex,sy,ey);
//A1,A2,A3是相应的圆心角
double A1=acos(rr/a);
double A2=acos(rr/c);
double A3=acos((a*a+c*c-e*e)/(*a*c));
double A4=A3-A1-A2;
double f=A4*rr;//弧长
printf("%.10f\n",f+b+d);
return ;
}
German Collegiate Programming Contest 2018 B. Battle Royale的更多相关文章
- German Collegiate Programming Contest 2018 C. Coolest Ski Route
John loves winter. Every skiing season he goes heli-skiing with his friends. To do so, they rent a h ...
- German Collegiate Programming Contest 2018 A. Attack on Alpha-Zet
题目链接https://nanti.jisuanke.com/t/28852 题目大意是 h*w 的平面,每两个点有且仅有一条路径,类似于封闭的联通空间,然后在这h*w个点中选取(标记为1~N)N个点 ...
- German Collegiate Programming Contest 2018
// Coolest Ski Route #include <iostream> #include <cstdio> #include <cstring> #inc ...
- 2018 German Collegiate Programming Contest (GCPC 18)
2018 German Collegiate Programming Contest (GCPC 18) Attack on Alpha-Zet 建树,求lca 代码: #include <al ...
- (寒假GYM开黑)2018 German Collegiate Programming Contest (GCPC 18)
layout: post title: 2018 German Collegiate Programming Contest (GCPC 18) author: "luowentaoaa&q ...
- ACM International Collegiate Programming Contest, Tishreen Collegiate Programming Contest (2018) Syria, Lattakia, Tishreen University, April, 30, 2018
ACM International Collegiate Programming Contest, Tishreen Collegiate Programming Contest (2018) Syr ...
- (寒假开黑gym)2017-2018 ACM-ICPC German Collegiate Programming Contest (GCPC 2017)
layout: post title: (寒假开黑gym)2017-2018 ACM-ICPC German Collegiate Programming Contest (GCPC 2017) au ...
- German Collegiate Programming Contest 2015 计蒜课
// Change of Scenery 1 #include <iostream> #include <cstdio> #include <algorithm> ...
- 2017-2018 ACM-ICPC German Collegiate Programming Contest (GCPC 2017)(9/11)
$$2017-2018\ ACM-ICPC\ German\ Collegiate\ Programming\ Contest (GCPC 2017)$$ \(A.Drawing\ Borders\) ...
随机推荐
- BNU 4096 逆序 思维题
https://www.bnuoj.com/v3/problem_show.php?pid=4096 对于一个序列a,我们定义它的逆序数为满足a[i]>a[j]且i<j的有序对<i, ...
- WebStorm技巧-在安卓手机上运行Ionic程序
打开菜单项 Run -> Run- 选择 Edit Configurations- 添加一个 PhoneGap/Cordova 配置项,命名如: Ionic Android, 并输入相关 ...
- c#基础 base和this的区别,在继承上面
base public Person(string name, int age, char gender) { this.Name = name; this.Age = age; this.Gende ...
- GitHub上优秀Android 开源项目
GitHub在中国的火爆程度无需多言,越来越多的开源项目迁移到GitHub平台上.更何况,基于不要重复造轮子的原则,了解当下比较流行的Android与iOS开源项目很是必要.利用这些项目,有时能够让你 ...
- iOS开发 - Protocol协议及委托代理(Delegate)
因为Object-C是不支持多继承的,所以很多时候都是用Protocol(协议)来代替.Protocol(协议)只能定义公用的一套接口,但不能提供具体的实现方法.也就是说,它只告诉你要做什么,但具体怎 ...
- Git命令图片版
- 大家一起和snailren学java-(序)
由于最近在面试实习的时候,发现自己的java基础还是不是特别的扎实.因此再重新深入学习一下java.每天学习一点,都能进步一些. 用书<Thinking in java><effec ...
- 洛谷 P1145 约瑟夫
题目描述 n个人站成一圈,从某个人开始数数,每次数到m的人就被杀掉,然后下一个人重新开始数,直到最后只剩一个人.现在有一圈人,k个好人站在一起,k个坏人站在一起.从第一个好人开始数数.你要确定一个最小 ...
- BZOJ 2851: 极限满月 虚树 or 树链的并
2851: 极限满月 Time Limit: 20 Sec Memory Limit: 512 MBSubmit: 170 Solved: 82[Submit][Status][Discuss] ...
- [神经网络]一步一步使用Mobile-Net完成视觉识别(四)
1.环境配置 2.数据集获取 3.训练集获取 4.训练 5.调用测试训练结果 6.代码讲解 本文是第四篇,下载预训练模型并训练自己的数据集. 前面我们配置好了labelmap,下面我们开始下载训练好的 ...