Lightoj 1297 - Largest Box

Memory Limit: 32 MB

In the following figure you can see a rectangular card. Thewidth of the card isW and length of the card is
L and thicknessis zero. Four(x*x) squares are cut from the four corners of the cardshown by the black dotted lines. Then the card is folded along the magentalines to make a box without a cover.

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

Input

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

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

Output

For each case, print the case number and the maximum volumeof the box that can be made. Errors less than10-6 will beignored.

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<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#define LL double
using namespace std;

double f(double l,double w)//必然和求导数有关,那么求完导数怎么求MAX V呢
{
    double a,b,c,k;
    a=12.0;b=-4.0*(l+w);c=l*w;//MAX V与所截得的X长度有关系,所以先求出X的值就解决了。求完导数剩下的一元二次方程,当根为0时取得极值。
     k=-b-sqrt(b*b-4*a*c);//这里取得左根
     k/=2*a;//K即为所求的X值。x=-b+-(sqrt(b^2-4ac))/2a;
     return  (l-2*k)*k*(w-2*k)  ;
}

int main()
{
    LL l,w,c,i,x,y;
    int cla;
    scanf("%lld",&cla);
    for(int gr=1; gr<=cla; gr++)
    {
        printf("Case %d: ",gr);
        scanf("%lf %lf",&l,&w);
        printf("%lf\n",f(l,w));
    }
    return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

时间: 2024-07-31 04:21:03

Lightoj 1297 - Largest Box的相关文章

light oj 1297 Largest Box

1297 - Largest Box   PDF (English) 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 is L and thickness is zero. Four (x*x) squares a

lightoj 1297(三分)

传送门:Largest Box 题意:长度为L宽度为W的纸四个角去掉x*x的正方形,然后形成一个长方体,问能组成长方体的最大体积为多少. 分析:三分x求最值. #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #define N 100010 #define mod 1000000007 #define LL long long #define lson l,

lightoj Basic Math 数论基础

这里是除去Beginners Problems后的部分 1020 - A Childhood Game 巴什博奕(Bash Game) #include<bits/stdc++.h> using namespace std; int main(void) { int t,Case=0; int n; char s[10]; scanf("%d",&t); while(t--) { scanf("%d%s",&n,&s); prin

light oj Basic Math 数论基础

这里是除去Beginners Problems后的部分 1020 - A Childhood Game 巴什博奕(Bash Game) #include<bits/stdc++.h> using namespace std; int main(void) { int t,Case=0; int n; char s[10]; scanf("%d",&t); while(t--) { scanf("%d%s",&n,&s); prin

LightOJ 1356 Prime Independence (素数 二分图)

Prime Independence Time Limit:3000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit Status Practice LightOJ 1356 Description A set of integers is called prime independent if none of its member is a prime multiple of another member. A

Windows10 使用Virtual Box一启动虚拟机就蓝屏(错误代码SYSTEM_SERVICE_EXCEPTION)解决方案

原文:Windows10 使用Virtual Box一启动虚拟机就蓝屏(错误代码SYSTEM_SERVICE_EXCEPTION)解决方案 一打开虚拟机电脑就立马蓝屏重启,新建虚拟机也没用,然后就开始百度,百度上全说什么驱动不对,然后我就卸载升级各种驱动,然后各种重装VirtualBox,还是不行,搞了一两个小时,都快放弃了.决定上个google,终于看到一篇文章说是因为Hyper-V与Virtual Box冲突了,只需要在控制面板关闭就行.然后抱着试一试的心态. 首先我们先打开控制面板.按Wi

(单调栈)poj-2559 Largest Rectangle in a Histogram

A histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have equal widths but may have different heights. For example, the figure on the left shows the histogram that consists of rectangles with the

215. Kth Largest Element in an Array

Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.For example,Given [3,2,1,5,6,4] and k = 2, return 5.Note:You may assume k is always valid, 1 ≤ k ≤ array's le

CloudFoundry in 1 Box简介:PCF-Dev篇

在<CloudFoundry in 1 Box简介:Bosh-lite篇>我们介绍了Bosh-lite的架构和部署.在本篇中,我们将详细描述另一个CloudFoundry in 1 Box解决方案PCF-Dev. 1PCF-dev简介 PCF是Pivotal发行的Cloud Foundry商业版,PCF-Dev原名MicroPCF,是Pivotal为PCF的应用开发人员准备的一款App单虚拟机版的CloudFoundry.但是,麻雀虽小,五脏俱全.PCF-Dev虽然可以在仅仅一台虚拟式上即可运