/*2bc*cosA=b^2+c^2-a^2 模拟计算 50分*/ #include<iostream> #include<cstdio> #include<cmath> using namespace std; const double t=3.1415926535898; int n; double a,b,c,x,y,z,x2,y2,z2,s,k,m,w,p; int main () { freopen ("standing.in","r",stdin); freopen ("standing.out","w",stdout); scanf ("%d",&n); for (int i=1;i<=n;i++) { scanf ("%lf%lf%lf%lf%lf%lf",&x,&y,&z,&x2,&y2,&z2); if (sqrt(abs(x-x2)*abs(x-x2)+abs(y-y2)*abs(y-y2))>z+z2) printf ("%.3lf\n",z*z*t+z2*z2*t); else if ((x+z>x2+z2&&x-z<x2-z2&&y+z>y2+z2&&y-z<y2-z2)||(x+z<x2+z2&&x-z>x2-z2&&y+z<y2+z2&&x-z>y2-z2)) printf ("%.3lf\n",max(z*z*t,z2*z2*t)); else { s=z*z*t+z2*z2*t; k=sqrt(abs(x-x2)*abs(x-x2)+abs(y-y2)*abs(y-y2)); a=(z*z-z2*z2+k*k)/(2*k); b=k-a; c=2*sqrt(z*z-a*a); w=(2*z*z-c*c)/(2*z*z); p=acos(w); m=(z+z+c)/2; s-=((p*z*z)/2-sqrt(m*(m-c)*(m-z)*(m-z))); c=2*sqrt(z2*z2-b*b); w=(2*z2*z2-c*c)/(2*z2*z2); p=acos(w); m=(z2+z2+c)/2; s-=((p*z2*z2)/2-sqrt(m*(m-c)*(m-z2)*(m-z2))); printf ("%.3lf\n",s); } } return 0; }
时间: 2024-11-07 06:11:33