hdu 6354 Everything Has Changed

Posted moomight

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了hdu 6354 Everything Has Changed相关的知识,希望对你有一定的参考价值。

18年杭电多校5的e题

链接:http://acm.hdu.edu.cn/showproblem.php?pid=6354

根据题意,第一个以后的圆不会相交,所以思路直接是通过余弦定理计算角度,然后求出弧长,进行加减得出答案。

代码:

技术图片
 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cstring>
 4 #include <algorithm>
 5 #include <cmath>
 6 using namespace std;
 7 const double pi = acos(-1.0);
 8 
 9 double dis(double x,double y)
10     double distance = sqrt(x*x+y*y);
11     return distance;
12 
13 
14 int main()
15 
16     int t;
17     cin>>t;
18     while(t--)
19         int m;
20         double x,y,r,r0;
21         scanf("%d %lf",&m,&r0);
22         double L = 2*pi*r0;
23         while(m--)
24             scanf("%lf %lf %lf",&x,&y,&r);
25             double distance = dis(x,y);
26             int dist1 = r0 + r;
27             int dist2 = r0 - r;
28             if(distance>=dist2&&distance<dist1) 
29                 double angela = acos((r0*r0 + distance*distance - r*r)/(2*distance*r0));
30                 double angelb = acos((r*r + distance*distance - r0*r0)/(2*distance*r));
31                 L -= 2*angela*r0;
32                 L += 2*angelb*r;
33             
34         
35         printf("%.20lf\n",L);
36         
37     return 0;
38 
View Code

 

以上是关于hdu 6354 Everything Has Changed的主要内容,如果未能解决你的问题,请参考以下文章

hdu6354 Everything Has Changed (圆的相交弧长)

HDOJ6354Everything Has Changed(计算几何)

hdu6354 /// 圆的相交

@loj - 6354@「CodePlus 2018 4 月赛」最短路

Mod, Or and Everything HDU - 6950

[hdu6595]Everything Is Generated In Equal Probability