lightoj--1294--Largest Box(三分)
| Time Limit: 2000MS | Memory Limit: 32768KB | 64bit IO Format: %lld & %llu |
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
#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(三分)的更多相关文章
- LightOJ - 1297 - Largest Box(数学)
链接: https://vjudge.net/problem/LightOJ-1297 题意: In the following figure you can see a rectangular ca ...
- LightOJ - 1297 Largest Box LightOJ(一元三次方程求极大值)
题目链接:https://vjudge.net/contest/28079#problem/K 题目大意:给你一个长为L,宽为W的纸片,四个角剪掉边长为x的正方形,如下图所示,然后折成一个无盖的纸盒, ...
- 1297 - Largest Box(三分)
1297 - Largest Box PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB In t ...
- light oj 1297 Largest Box
1297 - Largest Box PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB In t ...
- LightOJ - 1294 - Positive Negative Sign(规律)
链接: https://vjudge.net/problem/LightOJ-1294 题意: Given two integers: n and m and n is divisible by 2m ...
- lightoj 1297(三分)
传送门:Largest Box 题意:长度为L宽度为W的纸四个角去掉x*x的正方形,然后形成一个长方体,问能组成长方体的最大体积为多少. 分析:三分x求最值. #include <cstdio& ...
- uva 1463 - Largest Empty Circle on a Segment(二分+三分+几何)
题目链接:uva 1463 - Largest Empty Circle on a Segment 二分半径,对于每一个半径,用三分求出线段到线段的最短距离,依据最短距离能够确定当前R下每条线段在[0 ...
- UVA10215The Largest/Smallest Box(小数精度)
本身很容易却因为评测机有毒的一道题,,,看网上题解说最后一个答案要加一个很小的数才能AC,据说是因为没有speci judge #include <iostream> #include & ...
- HDU 4717The Moving Points warmup2 1002题(三分)
The Moving Points Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
随机推荐
- python学习-字符串 列表 元祖
目录 Python翻转字符串(reverse string) 简单的步长为-1, 即字符串的翻转(常用) 递归反转 借用列表,使用reverse()方法 字符串常用操作 index split 切片 ...
- C# txt文件操作
//打开文件到流 FileStream fs=new FileStream(path,FileMode.Open,FileAccess.ReadWrite); //写文件流的方法 StreamWrit ...
- DataTable和List相互转换的类
DataTable与List相互转换 .NET后台数据处理,从数据库中的捞出的数据格式一般是List和DataTable的格式.现在将两种格式相互转换的心得记录下来以便以后查找(直接上代码). pub ...
- Android View事件分发与传递
在Android中,人们主要通过手指与系统交互.Android把所有的touch事件都被封装成MotionEvent来进行处理,其中包括了手指点击的位置,时间等信息.其事件类型主要包括:ACTION_ ...
- Linq怎么支持Monad
在上一篇创建了我们的第一个Monad, Identity<T>. 我们确定了类型要变成Monad, 它必须有一个type constructor(Identity<T>), 和 ...
- 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 ...
- (转)使用Vue-Router 2实现路由功能
注意:vue-router 2只适用于Vue2.x版本,下面我们是基于vue2.0讲的如何使用vue-router 2实现路由功能.推荐使用npm安装. npm install vue-router ...
- 【Oracle】恢复丢失的临时表空间文件
Oracle 11g以后,临时表空间文件是可以在重启数据库以后自动生成的(当然也可以在相同目录再建一个临时表空间文件),模拟实验如下: 1)删除临时表空间数据文件 SYS@ENMOEDU> se ...
- NagiosQL安装
NagiosQL和Nconf是比较好用的Nagios配置工具. 一.安装NagiosQL 1.在服务器终端运行以下命令: ##YUM安装PHP模块yum -y install --disabl ...
- QT线程使用收集示例
关于多线程问题: Qt和Boost做跨平台的线程封装,OpenMP主要做并行计算,让不精通多线程的人也能高效地利用CPU的计算能力.个人倾向于用boost.thread, boost.mpi. 一 ...