真水题,看到这么短的代码眼泪都要感动的掉下来。
给你两根柱子之间的距离,一条绳子的两段分别绑在柱子上,一头牛由这根绳子限制,只能吃到这个椭圆面积的草。
问你椭圆的面积。
S = PI * a* b ( a,b为长短半轴
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
const double pi = acos(-1.0);
int main()
{
int n;
cin>>n;
while( n-- )
{
double d,l;
cin>>d>>l;
double half = l*0.5;
double sho = sqrt ( half * half - ( d * 0.5)*(d * 0.5) );
double lon = d*0.5 + (l-d)*0.5;
printf("%.3lf\n",pi*sho*lon);
}
return 0;
}