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. Core篇——初探IdentityServer4(客户端模式,密码模式)

    Core篇——初探IdentityServer4(客户端模式,密码模式) 目录 1.Oatuth2协议的客户端模式介绍2.IdentityServer4客户端模式实现3.Oatuth2协议的密码模式介 ...

  2. YCbCr to RGB and RGB toYCbCr

    RGB => YCbCr: Y = 0.299R + 0.587G + 0.114BCb = -0.1726R - 0.3388G + 0.5114B + 128Cr = 0.5114R - 0 ...

  3. 全局变量变为局部变量 & MVC思想

    1 函数中的全局变量如何变成局部变量? 全局变量之间会相互骚扰.所以在代码中不要用全局变量.ES6之前只有函数里面有全局变量. 全局变成局部变量怎么变? 把代-放在一个函数如中,再.call()执行一 ...

  4. React+webpack

    webPack + React 步骤: 1. 创建文件夹 src 源代码目录 main.js 打包的入口文件 App.js 项目的根组件 import React,{Component} from ' ...

  5. ProgressDialog的关键几个函数

    进度条对话框在开发是常见的一种工具,只要注意以下几点,就可以轻松使用. ProgressDialog.setMax(MAX_PROGRESS);  //设置最大值,可以如下定义一个常值 //priva ...

  6. WinRAR 5.60 无广告正式版

    首先明确WinRAR唯一的官网是这个 https://www.rarlab.com/ 其余的都不要相信. 现在的问题是:不要脸的中国代理强行捆绑广告:即使你花钱注册同样要面对弹窗广告!这就不可接受了! ...

  7. 3D特征:关于HFM和HBB

    1.HBB    三维绑定框 (1): 要用到HBB,定义还不太清楚,来自于 VALVE Developer Community (https://developer.valvesoftware.co ...

  8. pc页面滚动的时候,背景图不动只是页面滚动

    代码如下,直接拷贝出去就能看效果: 用到的方法 background-attachment 属性设置背景图像是否固定或者随着页面的其余部分滚动. <!DOCTYPE html> <h ...

  9. 【转】【Oracle 集群】ORACLE DATABASE 11G RAC 知识图文详细教程之RAC 工作原理和相关组件(三)

    原文地址:http://www.cnblogs.com/baiboy/p/orc3.html 阅读目录 目录 RAC 工作原理和相关组件 ClusterWare 架构 RAC 软件结构 集群注册(OC ...

  10. Linux下清空文件的几种方法

    $ : > filename $ > filename $ echo "" > filename $ echo > filename $ cat /dev/ ...