1297 - Largest Box
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 are cut from the four corners of the card shown by the black dotted lines. Then the card is folded along the magenta lines to make a box without a cover.

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

Input

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

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

Output

For each case, print the case number and the maximum volume of the box that can be made. Errors less than 10-6 will 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

题解:方程式列一下,因为是3次方,一看就是求极值的,但是注意范围是0,min(w,h)/2,三分写一下就过了。。。

代码:

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define mem(x,y) memset(x,y,sizeof(x))
#define ZR (4*W+4*L)*(4*W+4*L)-48*W*L
using namespace std;
const int INF=0x3f3f3f3f;
double L,W;
double js(double x){
return x*(L-*x)*(W-*x);
}
double sf(double l,double r){
double mid,mm;
while(r-l>1e-){
mid=(l+r)/;
mm=(mid+r)/;
if(js(mid)>=js(mm))r=mm;
else l=mid;
}
return mid;
}
int main(){
int T,flot=;
scanf("%d",&T);
while(T--){
scanf("%lf%lf",&L,&W);
double x=sf(,min(L,W)/);
// printf("%f\n",x);
printf("Case %d: %lf\n",++flot,js(x));
}
return ;
}

1297 - Largest Box(三分)的更多相关文章

  1. light oj 1297 Largest Box

    1297 - Largest Box   PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB In t ...

  2. LightOJ - 1297 - Largest Box(数学)

    链接: https://vjudge.net/problem/LightOJ-1297 题意: In the following figure you can see a rectangular ca ...

  3. LightOJ - 1297 Largest Box LightOJ(一元三次方程求极大值)

    题目链接:https://vjudge.net/contest/28079#problem/K 题目大意:给你一个长为L,宽为W的纸片,四个角剪掉边长为x的正方形,如下图所示,然后折成一个无盖的纸盒, ...

  4. lightoj 1297(三分)

    传送门:Largest Box 题意:长度为L宽度为W的纸四个角去掉x*x的正方形,然后形成一个长方体,问能组成长方体的最大体积为多少. 分析:三分x求最值. #include <cstdio& ...

  5. lightoj--1294--Largest Box(三分)

    Largest Box Time Limit: 2000MS   Memory Limit: 32768KB   64bit IO Format: %lld & %llu Submit Sta ...

  6. uva 1463 - Largest Empty Circle on a Segment(二分+三分+几何)

    题目链接:uva 1463 - Largest Empty Circle on a Segment 二分半径,对于每一个半径,用三分求出线段到线段的最短距离,依据最短距离能够确定当前R下每条线段在[0 ...

  7. UVA10215The Largest/Smallest Box(小数精度)

    本身很容易却因为评测机有毒的一道题,,,看网上题解说最后一个答案要加一个很小的数才能AC,据说是因为没有speci judge #include <iostream> #include & ...

  8. HDU 4717The Moving Points warmup2 1002题(三分)

    The Moving Points Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  9. HDU 4717 The Moving Points (三分)

    The Moving Points Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

随机推荐

  1. BZOJ 1996: [Hnoi2010]chorus 合唱队(dp)

    简单的dp题..不能更水了.. --------------------------------------------------------------- #include<cstdio&g ...

  2. $.ajax和vue-resource实现OAuth

    Vue.js——使用$.ajax和vue-resource实现OAuth的注册.登录.注销和API调用 概述 上一篇我们介绍了如何使用vue resource处理HTTP请求,结合服务端的REST A ...

  3. Delphi 常用属性说明(超长)

    Delphi组件的常用事件Onclick——当单击时触发这个事件中的代码Onchange——当改变该组件内容时触发其中的代码Oncreate——当创建时触发这个事件中的代码Onclose——当关闭的时 ...

  4. 应用 Valgrind 发现 Linux 程序的内存问题

    如何定位应用程序开发中的内存问题,一直是 inux 应用程序开发中的瓶颈所在.有一款非常优秀的 linux 下开源的内存问题检测工具:valgrind,能够极大的帮助你解决上述问题.掌握 valgri ...

  5. SpringBoot Quickstart

    SpringBoot Intro SpringBoot是顺应现在微服务(MicroServices)理念而产生的一个微框架(同类微框架可供选择的还有Dropwizard), 用来构建基于Spring框 ...

  6. WEB和APP谁是互联网未来

    据中国多家权威报告显示,作为多年专业化互联网公司炎帝网络科技综合评估预测,预计2016年全球互联网设备将达到100亿部.如果届时全球人口达到73亿,意味着平均每人将有1.4部设备.智能交通将增长50倍 ...

  7. JAVA GUI学习 - JInternalFrame浮动窗口:可拖拽窗口(依赖于父窗口)

    public class JInternalFrameKnow extends JInternalFrame { public JInternalFrameKnow() { this.setBound ...

  8. MaxSubArray 最大子数列和

    public int maxSubArray(int[] A) { int newsum=A[0]; int max=A[0]; for(int i=1;i<A.length;i++){ new ...

  9. poj 2503 Babelfish(Map、Hash、字典树)

    题目链接:http://poj.org/bbs?problem_id=2503 思路分析: 题目数据数据量为10^5, 为查找问题,使用Hash或Map等查找树可以解决,也可以使用字典树查找. 代码( ...

  10. android使用全局变量的两种方法

         在我们使用android编写程序的时候,少不了想利用全局变量,但是面向对象语言和过程语言区别很大,不再是include就可以的.这里我写了使用全局变量的两种方法: 1.使用applicati ...