UmBasketella
来源:互联网 发布:来分期可以在淘宝套现 编辑:程序博客网 时间:2024/06/04 00:31
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 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.
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
三分求最大值,注意多组输入和eps设置
#include<iostream>#include<cstdio>#include<cmath>using namespace std;const double eps=1e-8;const double pi=acos(-1.0);double s;double H(double r){ return sqrt(pow(s/(pi*r)-r,2.0)-r*r);}double V(double r){ return 1/3.0*pi*r*r*H(r);}int main(){ while(~scanf("%lf",&s)){ double mid,mmid,left=0,right=sqrt(s/(2*pi)); while(right-left>eps){ mid=(right+left)*0.5; mmid=(right+mid)*0.5; if(V(mid)-V(mmid)>eps) right=mmid; else left=mid; } printf("%.2f\n%.2f\n%.2f\n",V(left),H(left),left); } return 0;}
- UmBasketella
- UmBasketella
- UmBasketella
- 3737 UmBasketella
- POJ3737:UmBasketella
- [POJ3737]UmBasketella
- pku 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(三分)
- poj3737 UmBasketella [三分]
- day5 POJ 3737 UmBasketella
- poj3737 UmBasketella(三分)
- java io系列14之 DataInputStream(数据输入流)的认知、源码和示例
- 什么是装饰器?
- spring mvc简介
- Android基础系列----------- 资源适配
- C++素数判断法
- UmBasketella
- C语言常用库函数
- Resource相关 Android中asset文件夹和raw文件夹区别
- 设计模式(八)适配器模式
- bnu52326Just Convolution弱校联盟10.5【暴力?复杂度】
- android实现数据的MD5加密并用SharedPreferences存储
- (多图) 超强整理!PCB设计之电流与线宽的关系
- 字符串算法:最长公共子序列、最短编辑距离等
- Leetcode-66. Plus One