POJ-3737 UmBasketella(三分/数学)

Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 9846 Accepted: 3826

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

Source

PKU Campus 2009 (POJ Monthly Contest – 2009.05.17), cyqclark

 

这道题本来是用来练习三分的,可我发现,直接可以把结果推出来。

下面是直接推导的方法:

这里我们要求的是当体积最大的时候的r的值,那么就算是这个时候把体积增大几倍亦或者是进行平方操作,对r的大小也是没有影响的,所以我们可以通过对V乘以3然后平方得到一个函数来代替V,f(r)=s^2*r^2-2*pi*s^4;

对f(r)求导后利用数学知识可以得到体积最大的时候的r=sqrt(s/4/pi);

由S和r可以推导出高和体积。

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<math.h>
typedef  long long LL;
int INF=0x3f3f3f3f;
double dou=1e-15;//精度问题
using namespace std;
const double pi=3.1415926;

int main()
{
    while(cin>>s_all)
    {
        double rr=sqrt(s_all/4/pi);
        double ll=(s_all-pi*rr*rr)/pi/rr;
        double hh=sqrt(ll*ll-rr*rr);
        double vv=pi*rr*rr*hh/3.0;
        printf("%.2lf\n%.2lf\n%.2lf\n",vv,hh,rr);

    }
    return 0;
}

我对上述方法的理解为倒推,现在我们可以通过三分的方法去让电脑帮助我们完成正推,这样就不用在演草纸上面一点一点去进行简(ma)单(fan)的推导了!

找到底部半径的极限值,也就是说如果侧面无限向下直到与底面重合的时候,半径取最大,为sqrt(s/pi),最小的半径是0,此时代表一个无限长的线。

根据这个范围,我们采用三分的方法,一步一步逼近接近答案的那个数就行了。

大致方法是通过三分半径找到对应的母线长,通过母线长找到对应的高,通过高得出圆锥的体积,比较mid和midmid的体积大小就行了。

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<math.h>
typedef  long long LL;
int INF=0x3f3f3f3f;
double dou=1e-9;//精度问题
using namespace std;
const double pi=3.1415926;
double s,s_side,s_down,r,h,l;
double v;

double cal(double r)
{
    l=(s-pi*r*r)/pi/r;
    h=sqrt(l*l-r*r);
    v=pi*r*r*h/3;
    return v;
}

void sanfen(double ll,double rr)
{
    while(rr-ll>dou)
    {
        double num1=(ll+rr)/2.0;
        double num2=(num1+rr)/2.0;

        if(cal(num1)+dou<cal(num2))
            ll=num1;
        else
            rr=num2;
    }
    r=ll;
}

//0 - 100
int main()
{
    while(cin>>s)
    {
        sanfen(0,sqrt(s/pi));
        l=(s-pi*r*r)/pi/r;
        h=sqrt(l*l-r*r);
        v=pi*r*r*h/3;
        printf("%.2lf\n%.2lf\n%.2lf\n",v,h,r);
    }
    return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值