poj3737 UmBasketella(三分)
来源:互联网 发布:服务器80端口是什么 编辑:程序博客网 时间:2024/05/14 15:52
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 <iostream>#include <cstring>#include <algorithm>#include <iomanip>#include <cstdio>#include <cmath>using namespace std;double S;const double PI = acos(-1.0);const double eps = 0.0000000001;double calculate(double r){ double v = PI/3.0*r*r*sqrt(pow((S-PI*r*r)/(PI*r), 2) - r*r); return v;}int main(){ while(cin>>S){ double l = 0; double r = sqrt(S/PI); while(l+eps<r){ double mid = (l+r)/2; double mmid = (mid+r)/2; if(calculate(mid) < calculate(mmid)) l = mid; else r = mmid; } cout<<fixed<<setprecision(2)<<calculate(r)<<endl; cout<<fixed<<setprecision(2)<<sqrt(pow((S-PI*r*r)/(PI*r), 2) - r*r)<<endl; cout<<fixed<<setprecision(2)<<r<<endl; } return 0;}
- poj3737 UmBasketella [三分]
- poj3737 UmBasketella(三分)
- [复习][poj3737]三分 UmBasketella
- POJ3737:UmBasketella
- [POJ3737]UmBasketella
- [POJ3737]UmBasketella(三分法)
- poj3737(三分搜索)
- 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(三分)
- poj 3737 UmBasketella(三分)
- 搞懂UTF-8 和 GBK
- Eclipse下Android的DDMS中的的Abd问题
- 基于MATLAB GUI界面的MCU串口实时绘图设计
- Sunshine’s book(book)
- 【javase复习】## day9 IO---- File类 ##
- poj3737 UmBasketella(三分)
- 使用ListView、ViewPager、scrollView编写今日头条界面
- wget for windows 基本使用方法
- 玩无限消乐的设计示例(基础篇)消除动画元素操作
- spring_集成框架
- Android OpenGL ES学习笔记之添加颜色
- 初识pipeline
- JS中数组API的原理及基本功能
- dataTable study