2019 ACM-icpc 西安邀请赛Problem C Angel's Journey(几何数学题)

 


Problem c

Angel's Journey
Time limit. 1 second
Miyanel" This day Hana aks Miyako for help .again. Hana plays the part oot anuel on the stage show ofthecultural festival, and she is goinetolook FoeeHe oil Hinata. So she must find the shortest path toHinata's house
The area where angels live is a circle, and Hana lives at the bottom of this circie.coordinates of circle's centeris (rx rv) and its radiusisr. Hanawill liveat (rx,ry-r.
; located both outside the circle andApparently, there are many difficulties in this journey. The area which
, . . , . Aouhe area inside the circle is the holy land ofbelow the line y=ry is the sea, so Hana ,, cannot pass this area.
angels, Hana cannot pass this area neither.
However, Miyako canot aluate the length of the shortest path either. For the lveliest Hana in the world,
please help her solve this problem!

Input
Each test file contains several test cases. In each test tile:
The frst line contains a single integer T(1< T s 500) which is the number of test cases.
Each test case contains only one line with five integers: the coordinatesofcenter rx. ry, the radius r, the .coordinates of Hinata's house x. y. The test data guaranteesthat y>ry and (x,y) isout of the circle.
(10-srx,ry,x,ys 103,0<rS 10-).

Output  
For each test case, you should print one line with youranswer please keep 4 decimal places).

样例

输入

2

1 1  1 2 2 

1 1 1 1 3

输出
2.5708

3.8264

思路:过点做圆的切线,切点以前走圆弧,之后走直线。

#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <cstdio>
#include <map>
using namespace std;
typedef long long ll;
const int MAXN = 2e6+5;
ll  n,m,flag,flag1,ma,mi,ans,sum,T,k;
int a[MAXN],b[MAXN],dp[MAXN];
char c[MAXN];
int mapp[5001][5001];
string str,str1,str2;
set<char>  ss;
vector<char> v;
map<string,int> M;
bool judge(int x){if(x==2||x==3)return false;for(int i=2;i<=sqrt(x);i++){if(x%i==0)return true;}return false;}

double dis(double x,double y,double x1,double y1)
{
   return sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1));
}

int main()
{
    cin>>n;
   double pi=3.1415926;
   while(n--)
   {
       double rx,ry,r,x,y;
       cin>>rx>>ry>>r>>x>>y;
       double d;
       if(x>rx-r&&x<rx+r)
       {
           double d1,d2,d3,h,sina,sinb,a,b;
           d1=dis(x,y,rx,ry);
           d2=sqrt(d1*d1-r*r);
           h=d2*r/d1;
           sina=h/r;
           d3=dis(x,y,x,ry);
           sinb=d3/d1;
           a=asin(sina)*180/pi;
           b=asin(sinb)*180/pi;
           // cout<<a<<' '<<b<<endl;
           d=d2+(b-a)*pi*r/180+pi*r/2;
       }
       else if(x<=rx-r)
       {
            d=pi*r/2+dis(x,y,rx-r,ry);
       }
       else
       {
           d= d=pi*r/2+dis(x,y,rx+r,ry);
       }
       printf("%.4lf",d);
   }
   return 0;
}

西安赛怒打一铁,纪念一下封榜后才发现主办方改了样例的题目,同情很多做出了M题但没做出C的队伍,主办方欠你们一块牌。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值