#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
#define mem(x,y) memset(x,y,sizeof(x));
double l,w;
double solve(double e)
{
return (w-2*e)*(l-2*e)*e;
}
double sf(double l,double r)
{
double mid,mm;
while(r-l>1e-10)
{
mid=(l+r)/2;
mm=(mid+r)/2;
if(solve(mid)>=solve(mm))
r=mm;
else l=mid;
}
return mid;
}
int main()
{
int t;
int cnt=0;
scanf("%d",&t);
while(t--)
{
scanf("%lf%lf",&l,&w);
double x=sf(0,min(l,w)/2);
double pyl=solve(x);
printf("Case #%d: %.7lf\n",++cnt,pyl);
}
return 0;
}
light oj 1297 Largest Box
最新推荐文章于 2019-02-24 01:10:27 发布