lightoj1297 - Largest Box
2015-11-08 17:54
260 查看
1297 - Largest Box
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.
Each case starts with a line containing two real numbers L and W (0 < L, W < 100).
PDF (English) | Statistics | Forum |
Time Limit: 2 second(s) | Memory Limit: 32 MB |
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 |
#include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> using namespace std; double MAX(double a,double b){ return a>b?a:b; } int main() { int t,k=1; double l,w; scanf("%d",&t); while(t--){ scanf("%lf%lf",&l,&w); double x1=((4*l+4*w)+sqrt((4*l+4*w)*(4*l+4*w)-4.0*12.0*l*w))/(24.0); double x2=((4*l+4*w)-sqrt((4*l+4*w)*(4*l+4*w)-4.0*12.0*l*w))/(24.0); double ans=MAX((l-2*x1)*(w-2*x1)*x1,(l-2*x2)*(w-2*x2)*x2); printf("Case %d: %.10lf\n",k++,ans); } return 0; }
相关文章推荐
- 人生的高境界 - 无所谓
- 个人家园 - 永久免费ASP个人主页空间
- L.WuBi - 发布个最好用的在线五笔编码查询、五笔拆字图解
- 用hta实现制作的无殇 - 快书V1.1打包下载了第1/2页
- Windows SP2 免激活安装版 - DeepinXP PLUS V2 测试版 下载
- 超星图书浏览器(SSReader) v4.00 Bulid 070511 - 数字图书阅览器 下载
- Convenientfox v0.0.1.3 - 基于FireFox的浏览器 下载
- GX::Transcoder v3.20.51.3687 - 音频视频文件转换全能王 下载
- 某市大型汽车网 - vip代码提供下载了
- CSS属性 - white-space 空白属性使用说明
- 测试模式 - XSL教程 - 5
- 选择模式 - XSL教程 - 2
- 匹配模式 - XSL教程 - 4
- XPath入门 - XSL教程 - 3
- 强烈推荐 - Ajax 技术资源中心
- filewipe - 商用级文件擦除工具 提供下载了
- Javascript - HTML的request类
- 关于XSL - XSL教程
- JS创建优美的页面滑动块效果 - Glider.js
- 脚本中出现 window.open() access is denied - 拒绝访问 情况一则及分析