POJ 3737 UmBasketella.
来源:互联网 发布:淘宝追加评论后在哪看 编辑:程序博客网 时间:2024/05/06 07:17
Description
In recent days, people always design new things with multifunction. For instance, you can not only use cell phone to call your friends, but you can also use your cell phone take photographs or listen to MP3. Another example is the combination between watch and television. These kinds of multifunction items can always improve people's daily life and are extremely favored by users.
The company Mr. Umbrella invented a new kind umbrella "UmBasketella" for people in Rainbow city recently and its idea also comes from such multifunction--the combination of umbrella and daily necessities. This kind of umbrella can be used as a basket and you can put something you want to carry in it. Since Rainbow city rains very often, such innovative usage is successful and "UmBasketella" sells very well. Unfortunately, the original "UmBasketella" do not have an automatic volume control technology so that it is easily damaged when users try to put too many things in it. To solve this problem, you are needed to design an "UmBasketella" with maximum volume. Suppose that "UmBasketella" is a cone-shape container and its surface area (include the bottom) is known, could you find the maximum value of the cone?
Input
Input contains several test cases. Eash case contains only one real number S, representing the surface area of the cone. It is guaranteed that 1≤S≤10000.
Output
For each test case, output should contain three lines.
The first line should have a real number representing the maximum volume of the cone.
Output the height of the cone on the second line and the radius of the bottom area of the cone on the third line.
All real numbers should rounded to 0.01.
Sample Input
30
Sample Output
10.934.371.55==== 二分。#include<cstdio>#include<cmath>#define PI acos(-1.0)double cal(double r);double s;int main(){ double r,h,v; while(scanf("%lf",&s)==1) { double le=0,ri=sqrt(s/PI),rr; while(ri-le>1e-6) { r=(le+ri)/2; rr=(r+ri)/2; if(cal(r)>cal(rr)) ri=rr; else le=r; } r=(le+ri)/2; v=cal(r); h=3*v/PI/r/r; printf("%.2f\n%.2f\n%.2f\n",v,h,r); } return 0;}double cal(double r){if(((s-PI*r*r)*(s-PI*r*r)-r*r*r*r*PI*PI)<0) //注意这里的sqrt可能小于0.return 0; return r*sqrt((s-PI*r*r)*(s-PI*r*r)-r*r*r*r*PI*PI)/3.0;}
====
但这题也可以用数学解。#include<cstdio>#include<cmath>const double PI = acos(-1.0);int main(){ double s, r, h, v; while(scanf("%lf", &s) != EOF){ r = sqrt(s/PI)/2; h = sqrt((s*s)/(PI*PI*r*r) - 2*s/PI); v = PI*r*r*h/3; printf("%.2f\n%.2f\n%.2f\n", v, h, r); } return 0;}
- POJ 3737 UmBasketella 三分
- poj 3737 UmBasketella
- POJ 3737 UmBasketella
- poj 3737 UmBasketella 三分
- POJ 3737 UmBasketella.
- POJ 3737 UmBasketella
- POJ 3737 UmBasketella
- [POJ 3737]UmBasketella(三分)
- day5 POJ 3737 UmBasketella
- poj-3737(UmBasketella)
- POJ 3737 UmBasketella
- [POJ 3737][三分]UmBasketella
- POJ 3737 UmBasketella(三分)
- poj 3737 UmBasketella(三分+求导)
- POJ 3737 UmBasketella (数学)
- POJ 3737 UmBasketella(三分)
- POJ - 3737 - UmBasketella(三分)
- POJ 3737 UmBasketella 三分搜索
- Android缩放drawable
- Hadoop MapReduce进阶 使用DataJoin包实现Join
- ContextLoaderListener与DispatcherServlet所加载的applicationContext的区别
- 蓝桥杯 格子刷油漆(dp)
- #pragma STRUCT_ALIGN And #pragma pack明辨
- POJ 3737 UmBasketella.
- Objective C 对类变量的访问用 ./->
- ibatis使用遇到问题总结
- 人是能接受暗示的动物,和积极的人在一起吧
- HDU-1710 Binary Tree Traversals 二叉树遍历
- 三部排序
- 自己写的lua测试
- Hadoop MapReduce进阶 使用分布式缓存进行replicated join
- Jabberd/XMPP 学习之八:客户端-服务器示例