TheLargestSmallestBox/문보창 (rev. 1.1)
소감 ¶
2006-02-11 Accepted 0.117 448 |
코드 ¶
// 10215 - TheLagestSmallestBox
#include <iostream>
using namespace std;
#include <cmath>
#include <cstdio>
//#include <fstream>
//fstream fin("in.txt");
#define MIN(x,y) (((x) > (y)) ? (y) : (x))
static double L, W;
inline double func(double x)
{
return 4 * pow(x,3) - 2 * (L + W) * x * x + L * W * x;
}
void process()
{
double x1 = (2 * (L + W) + sqrt(pow(2 * (L + W),2) - 12 * L * W)) / 12.0;
double x2 = (2 * (L + W) - sqrt(pow(2 * (L + W),2) - 12 * L * W)) / 12.0;
double max = (func(x1) < func(x2)) ? x2 : x1;
double minValue = MIN(L,W) / 2.0;
printf("%.3f %.3f %.3f\n", max, 0.0, minValue);
}
int main()
{
while (cin >> L >> W)
process();
return 0;
}