比赛 20110722 评测结果 AWWWWWWWWW
题目名称 饥饿的母牛 最终得分 10
用户昵称 Pom 运行时间 0.000 s
代码语言 C++ 内存使用 0.00 MiB
提交时间 2011-07-22 10:10:49
显示代码纯文本
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>

using namespace std;

const double P=3.14159265;

double h,r,l,R,ans,a,b,c;
int DAT;

int main()
{
	freopen("hungry.in","r",stdin);
	freopen("hungry.out","w",stdout);
	scanf("%d",&DAT);
	for (int q=1;q<=DAT;q++)
	{
		scanf("%lf%lf%lf",&l,&h,&R);
		if (R<=h)
		{
			printf("%0.2lf\n",P*R*R);
			continue;
		}
		if (R<=sqrt(h*h+l*l/4))
		{
			printf("%0.2lf\n",P*R*R-acos(h/R)*R*R+h*sqrt(R*R-h*h));
			continue;
		}
		r=R-sqrt(h*h+l*l/4);
		ans=R*R*P;
		ans-=asin(0.5*l/(R-r))*R*R;
		ans+=P*r*r-asin(0.5*l/(R-r))*r*r;
		ans+=l*h/2;
		if (r+r<=l)
		{
			printf("%0.2lf\n",ans);
			continue;
		}
		b=l/2;
		a=sqrt(r*r-b*b);
		ans-=asin(a/r)*r*r-a*b;
		printf("%0.2lf\n",ans);
	}
	return 0;
}