POJ 3737 UmBasketella(三分模板)

本文介绍了一种名为UmBasketella的创新产品设计,该产品结合了雨伞和篮子的功能,特别适合雨水频繁的城市使用。文章提出了一项技术挑战:如何在已知圆锥形UmBasketella的全面积的情况下,确定其最大容量及其对应的几何参数,如高度和半径。通过三分法求解凸性函数的方法被用于寻找最优解决方案。
摘要由CSDN通过智能技术生成
UmBasketella
Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 6420 Accepted: 2503

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
 
给出一个圆锥的全面积,求出它的体积 高 和半径
三分可以求凸性函数,不断三分半径,使其越来越靠近极值
/*
   关于圆锥一些公式
   L * L =  h*h + r*r;         // 母线^2 = 高^2 + 底半径^2
   S = PI * r * (r+L)          //表面积 = 侧面积( π*r*L ) + 底面积 (π*r^2)
   V = PI * h * r*r *(1/3);    // 体积 = 底面积(π*r^2) * 高(h) * 1/3;

*/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <stdlib.h>
#include <algorithm>
#include <queue>
#include <map>
#include <cmath>
#define MAX 2000000
#define eps 1e-10
#define PI 3.1415926
using namespace std;
double s;
double Volume(double r)
{
    double L  = s/r/PI - r;
    double h  = sqrt(L*L - r*r);
    return PI*h*r*r/3 ;
}
int main()
{
    while(~scanf("%lf", &s))
    {
        double low = 0;
        double high = s / PI;
        double mid1, mid2;
        while(high - low > eps)
        {
            mid1 = low + (high - low) / 3;
            mid2 = high - (high - low) / 3;
            double v1 = Volume(mid1);
            double v2 = Volume(mid2);
            if(v1<v2)
                low = mid1;
            else high = mid2;
        }
        double ansL = s/low/PI - low;
        double ansh = sqrt(ansL*ansL - low*low);
        double ansv = PI*ansh*low*low/3 ;
        printf("%.2lf\n%.2lf\n%.2lf\n", ansv, ansh, low);
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值