给2圆求面积并 花式卡精度,这题告诉我们运输过程中应尽量避免出现π #includecstdio #includeiomanip #includecstring #includecstdlib #includealgorithm #includefunctional #includeiostream #includecmath #includecctype
给2圆求面积并
花式卡精度,这题告诉我们运输过程中应尽量避免出现π
#include<cstdio>#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<functional>
#include<iostream>
#include<cmath>
#include<cctype>
#include<ctime>
using namespace std;
#define For(i,n) for(int i=1;i<=n;i++)
#define Fork(i,k,n) for(int i=k;i<=n;i++)
#define Rep(i,n) for(int i=0;i<n;i++)
#define ForD(i,n) for(int i=n;i;i--)
#define RepD(i,n) for(int i=n;i>=0;i--)
#define Forp(x) for(int p=pre[x];p;p=next[p])
#define Forpiter(x) for(int &p=iter[x];p;p=next[p])
#define Lson (x<<1)
#define Rson ((x<<1)+1)
#define MEM(a) memset(a,0,sizeof(a));
#define MEMI(a) memset(a,127,sizeof(a));
#define MEMi(a) memset(a,128,sizeof(a));
#define INF (2139062143)
#define F (100000007)
#define pi (3.14159265358979323846264338324990142)
typedef long double ld;
typedef long long ll;
ll mul(ll a,ll b){return (a*b)%F;}
ll add(ll a,ll b){return (a+b)%F;}
ll sub(ll a,ll b){return (a-b+llabs(a-b)/F*F+F)%F;}
void upd(ll &a,ll b){a=(a%F+b%F)%F;}
int main()
{
// freopen("D.in","r",stdin);
// freopen(".out","w",stdout);
cout<<setprecision(10)<<setiosflags(ios::fixed);
ld x1,y1,r1,x2,y2,r2;
cin>>x1>>y1>>r1>>x2>>y2>>r2;
ld dis=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
if (dis>=r1+r2) cout<<"0\n";
else if (dis<=abs(r1-r2))
cout<<pi*min(r1,r2)*min(r1,r2)<<endl;
else {
ld _x=(dis*dis+r1*r1-r2*r2)/(2*dis);
ld _x2=(dis*dis-r1*r1+r2*r2)/(2*dis);
ld _xita=acos(_x/r1);
ld _xita2=acos(_x2/r2);
cout<<r1*r1*(_xita-sin(_xita)*cos(_xita))+r2*r2*(_xita2-sin(_xita2)*cos(_xita2))<<endl;
}
return 0;
}