比赛 |
20110722 |
评测结果 |
WWWWWWWWWW |
题目名称 |
饥饿的母牛 |
最终得分 |
0 |
用户昵称 |
Citron酱 |
运行时间 |
0.000 s |
代码语言 |
C++ |
内存使用 |
0.00 MiB |
提交时间 |
2011-07-22 11:56:02 |
显示代码纯文本
#include <fstream>
#include <cmath>
#include <iomanip>
#define I_F "hungry.in"
#define O_F "hungry.out"
#define MAXn 100
using namespace std;
double l[MAXn], d[MAXn], s[MAXn];
int n;
double ans[MAXn];
const double pi=3.14159265358979323946264338325027988;
void Input();
inline double Sqr(double);
inline double S1(double,double);
inline double S2(double,double);
void Sum();
void Output();
int main()
{
Input();
Sum();
Output();
return 0;
}
void Input()
{
ifstream fin(I_F);
fin>>n;
for (int i=0; i<n; i++)
fin>>l[i]>>d[i]>>s[i];
fin.close();
}
inline double Sqr(double x)
{
return (x*x);
}
inline double S1(double x, double r)
{
return (x/(pi*2)*Sqr(r));
}
inline double S2(double a, double h)
{
return (a*h/2);
}
void Sum()
{
for (int i=0; i<n; i++)
if (s[i]<=d[i])
ans[i]=S1(2*pi,s[i]);
else if (s[i]<=sqrt(Sqr(d[i])+Sqr(l[i]/2)))
ans[i]=(S1(pi-atan(l[i]/2/d[i]),s[i])+S2(l[i]/2,d[i]))*2;
else if ((s[i]-sqrt(Sqr(d[i])+Sqr(l[i]/2)))<=(l[i]/2))
ans[i]=(S1(pi-atan(l[i]/2/d[i]),s[i])+S1(pi-atan(d[i]*2/l[i]),s[i]-sqrt(Sqr(d[i])+Sqr(l[i]/2)))+S2(l[i]/2,d[i]))*2;
else
ans[i]=(S1(pi-atan(l[i]/2/d[i]),s[i])+S1(pi-atan(d[i]*2/l[i])-acos(l[i]/2/sqrt(Sqr(d[i])+Sqr(l[i]/2))),s[i])+S2(l[i]/2,d[i]+sqrt(Sqr(s[i]-sqrt(Sqr(d[i])+Sqr(l[i]/2)))-Sqr(l[i]/2))))*2;
}
void Output()
{
ofstream fout(O_F);
for (int i=0; i<n; i++)
fout<<setiosflags(ios::fixed)<<setprecision(2)<<ans[i]<<'\n';
fout.close();
}