三个圆的相交面积

http://acm.hzau.edu.cn/problem.php?id=1003

#include 
#include 
#include 
#include 
using namespace std;
void solve()
{
  double d, r;
  cin >> d >> r;
  double ans = 0;
  if (d < r) {
    double a = 3 * sqrt(3) * d * d / 4;
    double b = M_PI * r * r / 2;
    double c = r * r * acos(sqrt(3) * d / (2 * r)) - sqrt(3) * d / 2 * sqrt(r * r - d * d * 3 / 4);
    ans = a - b + 3 * c;
  }
  printf("%.2lf\n", ans);
}
int main()
{
//  freopen("input.txt", "r", stdin);
  int t;
  scanf("%d", &t);
  for (int i = 0; i < t; i++) {
    solve();
  }
}


你可能感兴趣的:(几何,经典例题)