Light OJ 1297 Largest Box

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.