标签:pac bsp += view event string pen problem scan
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 }
hdu 6354 Everything Has Changed
标签:pac bsp += view event string pen problem scan
原文地址:https://www.cnblogs.com/moomight/p/11246700.html