题意:给你一个以原点为圆心,R为半径的圆,再给你m个其他圆,切割m个圆的圆周,问最终大圆的外部周长为多少
思路:用余弦定理可以求出扇形的弧长所对应的圆心角的一半,弧长=圆心角×半径,求出对应的弧长
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
double P=acos(-1);
int main()
{
int t,m;
double R;
scanf("%d",&t);
while(t--)
{
scanf("%d%lf",&m,&R);
double c=2*P*R;
while(m--)
{
double x,y,r;
scanf("%lf%lf%lf",&x,&y,&r);
double dis=sqrt(x*x+y*y);
if(dis>=(r+R))
continue;
else if(dis>fabs(R-r))
c=c+r*2*acos((dis*dis+r*r-R*R)/(2.0*dis*r))-R*2*acos((R*R+dis*dis-r*r)/(2.0*R*dis));
else if(dis==fabs(R-r)&&R>=r)
c+=2*P*r;
}
printf("%.20lf\n",c);
}
return 0;
}