# The Largest/Smallest Box..

The Largest/Smallest Box..

The following figure shows a rectangular card of width W, length L, and thickness 0. Four x x x squares are cut from the four corners of the card shown by the dotted lines. The card is then folded along the dashed lines to make a box without a cover. Given the width and height of the box, find the values of x for which the box has maximum and minimum volume.

The input file contains several lines of input. Each line contains two positive floating point numbers L ( 0 < L < 10, 000) and W ( 0 < W < 10, 000), which indicate the length and width of the card, respectively.

For each line of input, give one line of output containing two or more floating point numbers separated by a single space. Each floating point number should contain three digits after the decimal point. The first number indicates the value which maximizes the volume of the box, while the subsequent values (sorted in ascending order) indicate the cut values which minimize the volume of the box.

``````1 1
2 2
3 3

``````

``````0.167 0.000 0.500
0.333 0.000 1.000
0.500 0.000 1.500

``````

``````#include <stdio.h>
#include <math.h>
double eps=1e-7;
int main(){
double ll,ww;
while(scanf("%lf%lf",&ll,&ww)==2){
double a=12;
double b=-4*(ll+ww);
double c=ll*ww;
double x=(-b-sqrt(b*b-4*a*c))/(2*a),x2=ll>ww?ww/2:ll/2;
printf("%.3lf %.3lf %.3lf\n",x,0.0,x2+eps);
}
return 0;
}``````

``````#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
double x1,x2;
double l,w;
cout<<setiosflags(ios::fixed)<<setprecision(3);
while(cin>>l>>w)
{
x1=sqrt(((l+w)*(l+w)/3-w*l)/12)+(l+w)/6;
x2=-sqrt(((l+w)*(l+w)/3-w*l)/12)+(l+w)/6;
cout<<x2<<" 0.000 "<<x1<<endl;
}
return 0;
}
``````