Time Limit: 2000MS   Memory Limit: 32768KB   64bit IO Format: %lld & %llu

Submit
Status

Description

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

3

2 10

3.590 2.719

8.1991 7.189

Sample Output

Case 1: 4.513804324

Case 2: 2.2268848896

Case 3: 33.412886

Source

Problem Setter: Shahriar Manzoor
Special Thanks: Jane Alam Jan (Description, Solution, Dataset)

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
double w,l;
double v(double x)
{
return (l-2*x)*(w-2*x)*x;
}
double san(double l,double r)
{
double mid,mm;
while(r-l>1e-10)
{
mid=(l+r)/2;
mm=(mid+r)/2;
if(v(mid)>=v(mm)) //谁大在谁的附近找
r=mm;
else
l=mid;
}
return mid;
}
int main()
{
int t;
int Case=1;
scanf("%d",&t);
while(t--)
{
scanf("%lf%lf",&w,&l);
double num=san(0,min(w,l)/2);
printf("Case %d: %lf\n",Case++,v(num));
}
return 0;
}

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

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

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

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

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

  3. 1297 - Largest Box(三分)

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

  4. light oj 1297 Largest Box

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

  5. LightOJ - 1294 - Positive Negative Sign(规律)

    链接: https://vjudge.net/problem/LightOJ-1294 题意: Given two integers: n and m and n is divisible by 2m ...

  6. lightoj 1297(三分)

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

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

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

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

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

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

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

随机推荐

  1. Kafka .NET操作

    Kafaka .NET连接 Kafka目前主流在用的.NET客户端有两个:一个是kafka-net,另外一个是Confluent.Kafka,这里给出使用示例: kafka-net示例: public ...

  2. guice基本学习,guice的学习资料(十)

    这个是我前面几篇的参考. guice的学习资料下载:http://pan.baidu.com/s/1bDEPem 路途遥远,但是人确在走.不忘初心,方得始终.

  3. BZOJ4518: [Sdoi2016]征途(dp+斜率优化)

    Time Limit: 10 Sec  Memory Limit: 256 MBSubmit: 1875  Solved: 1045[Submit][Status][Discuss] Descript ...

  4. App Store兼容性问题

    app下载出现兼容性问题  项目支持9.0以上的系统 但是10.3的iphone5下载的一直是老版本app  下载时提示不兼容 导致无法正常使用 解决办法: 修改Build-Settings-> ...

  5. Solid Angle of A Cubemap Texel - 计算Cubemap的一个像素对应的立体角的大小

    参考[http://www.rorydriscoll.com/2012/01/15/cubemap-texel-solid-angle/] 计算diffuse irradiance map或者求解sh ...

  6. 关于Eclipse安装Scala插件不显示

    关于Eclipse安装Scala插件不显示, 改变java版本仍然不能使用, 办法还是有的:下载Eclipse Scala版本 解压使用 下载在这里:http://scala-ide.org/down ...

  7. 『MicroPython』Hello uPy

    官网买了几乎全套.一路曲折:7月10号下单,13号发货,14号法兰克福过关,23号到北京,25号到上海,27号到沪C:沪C邮局投3次未果,中彩票一样终于打通了投递部电话才在次日28号“妥投”:又因出差 ...

  8. JeeSite 4.0 规划(二)

    ==== 点击放大查看 ==== ==== 点击放大查看 ====

  9. Visual Studio 2015中 安卓环境 cannot find adb.exe in specified sdk path

    安装完成后 发现 C:\Program Files (x86)\Android\android-sdk\platforms 是空的,用SDK Manager进行安装时发现 它需要往C:\Program ...

  10. 对服务器磁盘、CPU、内存使用状态,设置163邮件告警

    1,桥接模式可上网,首先你的邮箱已经开通yum -y install mailx dos2unix.x86_64  mailx -V[root@localhost ~]# vim /etc/mail. ...