1297-largest Box
|
PDF (中文版) |
Statistics |
Forum |
| 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 are L and thickness is zero. Four (x*x) squares is cut from the four corners of the "the" card shown by the black dotted lines. Then the card was folded along the magenta lines to make a box without a cover.
Given the width and height of the box, you'll have a to find the maximum volume of the box you can do for any value of C0>x.
Input
Input starts with an integer T (≤10000), denoting the number of test cases.
Each case starts with a line containing the real numbers L and W (0 < L, W <).
Output
For each case, print the case number and the maximum volume of the box that can is made. Errors less than 10-6 'll 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 |
Find a derivative.
#include <stdio.h> #include <string.h> #include <math.h> #include <algorithm> #define DD Doubleusing namespace Std;dd w,l;dd F (DD x) {return x* (w-2*x) * (l-2*x);} int main () {int t,k,i;scanf ("%d", &t), K=1;while (t--) {scanf ("%lf%lf", &l,&w);DD b= ( -4) * (w+l);DD a=12;dd c=w *l;dd x1= (sqrt (b*b-4*a*c)-B)/(2*a);DD x2= (-sqrt (b*b-4*a*c)-B)/(2*a);p rintf ("Case%d:", k++);p rintf ("%.7lf\n", Max (f (x1), F (x2)));} return 0;}
Light OJ 1297 Largest Box