题意:
给三个圆的半径,其中有两个是相等的。求一个圆的最小面积,能包含这三个圆,并且使这三个圆两两没有任何公共点(不相交,不相包含)
思路:
如图,在该三角形中用两次勾股定理就能得出R。
当然有其他情况(样例3):
这种情况R = 2*a 即可。
这种特殊情况的临界条件是第三个圆与大圆也相切。
计算得: b =2*R/3
代码:
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
const double PI = 2*acos(0);
int t, a, b, c;
double ans;
int main()
{
scanf("%d", &t);
while (t --)
{
scanf("%d %d %d", &a, &b, &c);
if (a > b) swap(a, b);
if (a > c) swap(a, c);
if (b > c) swap(b, c);
if (a == b) b = c;
else {b = a; a = c; }
if (b <= 2.0*a/3) ans = PI * a*2 * a*2;
else
{
ans = a*b + b*b + b*sqrt(b*b+2.0*a*b);
ans /= (b-a+sqrt(b*b+2.0*a*b));
ans *= ans*PI;
}
printf("%.3lf\n", ans);
}
}