standing

时间:2023-05-21 22:19:07
standing

standing

standing

standing

2bc*cosA=b^2+c^2-a^2

standing

#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
const double pi=3.1415926535898;//我不明白他为什么会卡精度
int t;
double x1,y,r1,x2,y2,r2,s,a,b,c,k,m,w,p;
int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%lf%lf%lf%lf%lf%lf",&x1,&y,&r1,&x2,&y2,&r2);
double d=sqrt((x2-x1)*(x2-x1)+(y2-y)*(y2-y);
if(d>=(r1+r2))//两圆相离
s=pi*r1*r1+pi*r2*r2;
else
if(d<abs(r1-r2))//两圆内含
s=max(pi*r1*r1,pi*r2*r2);
else//两圆相交
{
s=r1*r1*pi+pi*r2*r2;
k=sqrt((x1-x2)*(x1-x2)+(y-y2)*(y-y2)); w=(r1*r1+k*k-r2*r2)/(*r1*k);
p=*acos(w);
s-=((p*r1*r1)/-sin(p)*r1*r1/); w=(r2*r2+k*k-r1*r1)/(*r2*k);
p=*acos(w);
s-=((p*r2*r2)/-sin(p)*r2*r2/);
}
printf("%.3lf\n",s);
}
return ;
}

只要数学学得好代码就打得好