light oj 1297 Largest Box
来源:互联网 发布:centos yum配置 编辑:程序博客网 时间:2024/06/08 06:42
#include<iostream>#include<cstring>#include<cstdio>#include<math.h>using namespace std;double l,w;double g(double x){return 12*x*x-4*(l+w)*x+l*w;}int main(){int t;double left,right,mid;int k=1;scanf("%d",&t);while(t--){scanf("%lf%lf",&l,&w);printf("Case %d: ",k);k++;if(l>w)right=w/2.0;elseright=l/2.0;left=0.0;while(right-left>1e-8){mid=(right+left)/2.0;if(g(mid)<0)right=mid;elseleft=mid;}printf("%.7lf\n",(l-2*mid)*(w-2*mid)*mid);}return 0;} 下面是方程组法
#include<iostream>#include<cstring>#include<math.h>#include<cstdio>using namespace std;int main(){int t;scanf("%d",&t);int k=1;while(t--){double l,w;scanf("%lf%lf",&l,&w);printf("Case %d: ",k);k++;double x,a,b,c;a=12.0;b=-4.0*(w+l);c=w*l*1.0;x=(-b-sqrt(b*b-4*a*c))/(2*a);printf("%.7lf\n",(l-2*x)*(w-2*x)*x);}return 0;}
0 0
- light oj 1297 Largest Box
- light oj 1297 Largest Box
- light oj 【数论】1297 - Largest Box【三分】
- 【Light】[1297]Largest Box
- Light OJ 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 【函数最值】
- LightOJ 1297 Largest Box【简单计算几何】
- LightOJ 1297 - Largest Box (二分查找)
- lightoj 1297 - Largest Box 三分查找
- light oj
- light oj
- Light OJ
- 最大公约数和最小公倍数问题(天梯)
- mybatis-dao添加案例
- EJB的分类简介
- HTTP Header 详解
- Visual Basic .NET
- light oj 1297 Largest Box
- 河南第五届ACM省赛(Divideing Jewels)
- 39. Combination Sum LeetCode
- libpcap使用示例
- MYSQL 主从复制
- Android开发之Service
- 位置参数变量
- 109. Convert Sorted List to Binary Search Tree LeetCode
- 【010】Xcode7编译时App installation failed There was an internal API error.