您的位置:首页 > 其它

lightoj1297 - Largest Box

2015-11-08 17:54 260 查看
1297 - Largest Box



PDF (English)StatisticsForum
Time Limit: 2 second(s)Memory Limit: 32 MB
In the following figure you can see a rectangular card. The width of the card is W and length of the card is L and thickness is zero. Four (x*x) squares are cut from the four corners of the card shown by
the black dotted lines. Then the card is folded along the magenta lines to make a box without a cover.



Given the width and height of the box, you will have to find the maximum volume of the box you can make for any value of x.

Input

Input starts with an integer T (≤ 10000), denoting the number of test cases.

Each case starts with a line containing two real numbers L and W (0 < L, W < 100).

Output

For each case, print the case number and the maximum volume of the box that can be made. Errors less than 10-6 will be ignored.

Sample Input

Output for Sample Input

3

2 10

3.590 2.719

8.1991 7.189

Case 1: 4.513804324

Case 2: 2.2268848896

Case 3: 33.412886

 

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
double MAX(double a,double b){
return a>b?a:b;
}
int main()
{
int t,k=1;
double l,w;
scanf("%d",&t);
while(t--){
scanf("%lf%lf",&l,&w);
double x1=((4*l+4*w)+sqrt((4*l+4*w)*(4*l+4*w)-4.0*12.0*l*w))/(24.0);
double x2=((4*l+4*w)-sqrt((4*l+4*w)*(4*l+4*w)-4.0*12.0*l*w))/(24.0);
double ans=MAX((l-2*x1)*(w-2*x1)*x1,(l-2*x2)*(w-2*x2)*x2);
printf("Case %d: %.10lf\n",k++,ans);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  lightoj1297 - Larges