C++——三分答案模板——UmBasketella
来源:互联网 发布:剑灵火炮兰捏脸数据 编辑:程序博客网 时间:2024/06/05 17:43
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.93
4.37
1.55
#include<iostream>#include<cstdio>#include<cmath>using namespace std;double pi=acos(-1.0);double s;inline double calc(const double &r){double l=(s-r*r)/r;double h=sqrt(l*l-r*r);double v=pi*r*r*h/3.0;return v;}int main(){while(scanf("%lf",&s)!=EOF){s/=pi;double lft=0,rgt=sqrt(s),m1,m2,r;for(int t=0;t<200;++t){m1=lft+(rgt-lft)/3.0;m2=rgt-(rgt-lft)/3.0;if(calc(m1)<=calc(m2)) lft=m1,r=m2;else rgt=m2,r=m1;}double l=(s-r*r)/r;double h=sqrt(l*l-r*r);double v=pi*r*r*h/3.0;printf("%0.2f\n%0.2f\n%0.2f\n",v,h,r);}return 0;}
- C++——三分答案模板——UmBasketella
- POJ 3737 UmBasketella(三分模板)
- POJ 3737 UmBasketella 三分
- poj 3737 UmBasketella 三分
- [POJ 3737]UmBasketella(三分)
- poj3737 UmBasketella [三分]
- poj3737 UmBasketella(三分)
- [POJ 3737][三分]UmBasketella
- [复习][poj3737]三分 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 (三分)
- HDOJ 4355 —— 三分
- activiti工作流的web流程设计器整合视频教程 SSM和独立部署
- 划分型DP
- ajax中的POST和GET传值
- 十进制数转换成二进制数
- xpages从Excel中导入数据
- C++——三分答案模板——UmBasketella
- 后台获取Form中的值
- get_browser()用法
- 实现Android后台发邮件
- C++ 深拷贝与浅拷贝
- 九度 oj 题目1480:最大上升子序列和
- iOS利用runtime追踪对象的每一个方法
- Android 日常开发总结的技术经验 60 条
- 为什么java bean里面不用基本类型作为字段?