lightoj--1294--Largest Box(三分)
来源:互联网 发布:高中数学刷题软件 编辑:程序博客网 时间:2024/06/06 02:38
SubmitStatus
Description
In the following figure you can see a rectangular card. The width of the card isW 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 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 L andW (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 than10-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;elsel=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 三分查找
- Lightoj 1297 - Largest Box
- lightoj 1297 - Largest Box
- lightoj 1297 Largest Box
- LightOJ 1297: Largest Box【数学】
- lightOJ 1297 - Largest Box 【数学题】
- LightOJ 1297 - Largest Box【二分】
- LightOJ 1297 - Largest Box (一元三次方程求最大值)
- light oj 【数论】1297 - Largest Box【三分】
- lightoj 1297 - Largest Box 【函数最值】
- LightOJ 1297 Largest Box【简单计算几何】
- LightOJ 1297 - Largest Box (二分查找)
- lightoj LargestBox 1297 (三分)
- lightoj 1146 - Closest Distance(三分)
- lightOJ 1214 Largest Division
- lightoj1297 - Largest Box
- 【Light】[1297]Largest Box
- Activity基本知识
- Oracle 11g重建控制文件——控制文件全部丢失,从零开始
- Foundation框架中日期的操作
- Eclipse下开发maven项目出现稀奇古怪的问题
- eclipse安装tomcat插件及配置tomcat
- lightoj--1294--Largest Box(三分)
- 正向代理、反向代理、Url重写
- Android使用限定符
- log4j(日志记录器)
- 已知三角形三点坐标, 求三角形的面积
- RxJava初体验
- 如何反编译APK?
- 反射原理机制和应用
- LightOJ 1294:Positive Negative Sign