【题意】两个圆的面积交。
【解题方法】随便算一算就好了,水题
【AC 代码】
#include <bits/stdc++.h>
using namespace std;
const double PI=acos(-1);
#define ll long long
ll x1,y1,r1;
ll x2,y2,r2;
ll sq(ll x){
return x*x;
}
double circlejiao()
{
double ret = 0;
long long dis = sq(x1 - x2) + sq(y1 - y2);
if(dis >= sq(r1 + r2)) return 0;
if(dis <= sq(abs(r1 - r2))) return PI * sq(min(r1, r2));
double alpha = 2 * acosl((sq(r1) + dis - sq(r2)) / 2.0 / r1 / sqrt(dis));
double beta = 2 * acosl((sq(r2) + dis - sq(r1)) / 2.0 / r2 / sqrt(dis));
ret += 0.5 * (alpha * sq(r1) + beta * sq(r2));
ret -= 0.5 * (sinl(alpha) * sq(r1) + sinl(beta) * sq(r2));
return ret;
}
int main()
{
cin>>x1>>y1>>r1;
cin>>x2>>y2>>r2;
double ans=circlejiao();
printf("%.12f\n",ans);
}