lightoj 1297 - Largest Box
2015-11-08 16:54
302 查看
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<stdio.h> #include<string.h> #include<math.h> int main() { int T,k=1; double l,w,v,x; scanf("%d",&T); while(T--) { scanf("%lf%lf",&l,&w); double kai=sqrt(l*l+w*w-l*w); x=((l+w)-kai)/6; v=(w-2*x)*(l-2*x)*x; //v=(l+w-kai)*(2*l-w-kai)*(2*w-l-kai)/54; printf("Case %d: %.10lf\n",k++,v); } return 0; }
相关文章推荐
- 重温OSPF——OSPF邻居建立
- 【CS学习】——UML九种图
- MATLAB中classify函数的使用
- 软考路之考后总结
- dlopen函数的多平台性。
- 揭秘川大最牛女生寝室
- Oracle的instr函数使用
- linux下安装nginx
- MySQL优化
- java生成指定范围的随机数
- 随机森林的简单实现
- android Socket用法详解
- MyEclipse10中安装activiti插件后,新建activiti项目未显示maven dependencies
- 递归调用的实例讲解
- lightoj 1294 - Positive Negative Sign
- Enumeration接口
- oracle数据库中设置系统用户密码
- Java中关键字
- c++实现简单的线程池
- 高效敏感词过滤JAVA实现(DFA算法)