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的更多相关文章

  1. 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 ...

  2. German Collegiate Programming Contest 2018​ A. Attack on Alpha-Zet

    题目链接https://nanti.jisuanke.com/t/28852 题目大意是 h*w 的平面,每两个点有且仅有一条路径,类似于封闭的联通空间,然后在这h*w个点中选取(标记为1~N)N个点 ...

  3. German Collegiate Programming Contest 2018​

    // Coolest Ski Route #include <iostream> #include <cstdio> #include <cstring> #inc ...

  4. 2018 German Collegiate Programming Contest (GCPC 18)

    2018 German Collegiate Programming Contest (GCPC 18) Attack on Alpha-Zet 建树,求lca 代码: #include <al ...

  5. (寒假GYM开黑)2018 German Collegiate Programming Contest (GCPC 18)

    layout: post title: 2018 German Collegiate Programming Contest (GCPC 18) author: "luowentaoaa&q ...

  6. 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 ...

  7. (寒假开黑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 ...

  8. German Collegiate Programming Contest 2015 计蒜课

    // Change of Scenery 1 #include <iostream> #include <cstdio> #include <algorithm> ...

  9. 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\) ...

随机推荐

  1. Jenkins+Gitlab+Ansible自动化部署(一)

    首先准备实验环境 虚拟机 主机名 IP地址 服务 系统版本 内核版本 Vmware Workstation 14 gitlab.example.com 192.168.244.130 gitlab  ...

  2. 动态时间规整DTW

    动态时间规整DTW 1 概述 动态时间规整是一个计算时间序列之间距离的算法,是为了解决语音识别领域中语速不同的情况下如何计算距离相似度的问题. 相对于用经典的欧式距离来计算相似度而言,DTW在数据点个 ...

  3. (译)Minimal Shader(最小的着色器)

    (原文:https://en.wikibooks.org/wiki/Cg_Programming/Unity/Minimal_Shader) This tutorial covers the basi ...

  4. Spring Cloud--Feign服务调用组件的使用实例

    引入依赖: 启动类上添加@EnableFeignClients注解: 写调用接口: 直接@Autowired注入服务调用接口: 底层使用了动态代理,对接口进行了实现. 并且封装了RestTemplat ...

  5. HBuilder 做移动端app流程

    1.新建一个移动项目 2.编写代码 3.发行-发行为原生安装包,配置参数 选择icon 和引导页

  6. Android Studio 编译错误 Error:Execution failed for task ':app:buildInfoDebugLoader'.

    今天来到打开昨天的项目运行正常,然后改动了一点代码编译报错: Error:Execution failed for task ':app:buildInfoDebugLoader'. > Exc ...

  7. Viewcontroller基类

    #import <UIKit/UIKit.h> #import "YQZMutableArray.h" @interface YQZViewController : U ...

  8. hdu 3861 The King’s Problem

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission( ...

  9. python基础教程总结13——网络编程,

    1.网络设计模块 1.1 socket模块    根据连接启动的方式以及本地套接字要连接的目标,套接字之间的连接过程可以分为三个步骤:服务器监听,客户端请求,连接确认. 1)服务器监听:是服务器端套接 ...

  10. code Gym 100500D T-shirts(暴力)

    因为只能买一次,暴力枚举一下买的衣服的大小. #include<cstdio> #include<map> #include<algorithm> using na ...