POJ - 3737 - UmBasketella(三分)

来源:互联网 发布:oracle sql循环语句 编辑:程序博客网 时间:2024/05/18 20:10

UmBasketella
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 6554 Accepted: 2550

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


题意:给出一个圆锥的表面积(包含底面), 求该圆锥的最大体积,以及此时的底面半径和高


学习三分的第一道题目,最开始一看数学题已经晕了一半,公式不想推整个人都很颓。然后前天下午硬着头皮写了写,发现。。只要知道圆锥面积和体积公式就好了。。。没有什么需要推倒的公式orz.........

圆锥面积公式:

圆锥体积公式:v = π * r * r * h / 3


因底面半径为0或无穷大,该圆锥体积都为0,则函数近似于二次函数,所以三分

三分半径可根据面积公式得出高,然后计算体积即可。

最大初始值看题解有个很巧的方法:假设最开始侧面积与底面积重合的极限状态,则表面积是底面积的两倍


#include <iostream>#include <algorithm>#include <cstdio>#include <stdlib.h>#include <cmath>#include <cstring>#include <stack>#include <queue>#include <set>#include <map>#include <functional>#include <vector>#include <fstream>#include <iomanip>#define PI acos(-1.0)using namespace std;double s;double cal(double r){  double R = s / PI / r - r;  //r底面半径  double h = sqrt(R * R - r * r);  //h圆锥高  return PI * r * r * h / 3;   //体积}int main(){  while(scanf("%lf", &s) != EOF) {    double left = 0.0, right = sqrt(s / PI);    double m1, m2;    double v1, v2;    while(right - left > 1e-6) {      m1 = left + (right - left) / 3;      m2 = right - (right - left) / 3;      v1 = cal(m1);      v2 = cal(m2);      if(v1 < v2) left = m1;      else right = m2;    }    double R = s / PI / left - left;    double h = sqrt(R * R - left * left);    double v = PI * left * left * h / 3;    printf("%.2f\n%.2f\n%.2f\n", v, h, left);  }  return 0;}





0 0
原创粉丝点击