zoukankan      html  css  js  c++  java
  • UmBasketella

    UmBasketella

    http://poj.org/problem?id=3737

    Time Limit: 1000MS   Memory Limit: 65536K
    Total Submissions: 9489   Accepted: 3674

    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

     
     

    三分模板题

     1 #include<cstdio>
     2 #include<cmath>
     3 using namespace std;
     4 #define lson l,mid,rt<<1
     5 #define rson mid+1,r,rt<<1|1
     6 #define sqr(x) ((x)*(x))
     7 #define pb push_back
     8 #define eb emplace_back
     9 #define maxn 1000006
    10 #define eps 1e-8
    11 #define pi acos(-1.0)
    12 #define rep(k,i,j) for(int k=i;k<j;k++)
    13 typedef long long ll;
    14 typedef unsigned long long ull;
    15 
    16 double s;
    17 
    18 double cal(double r){
    19     double l=s/pi/r-r;
    20     double h=sqrt(l*l-r*r);
    21     double v=pi*r*r*h/3.0;
    22     return v;
    23 }
    24 
    25 int main(){
    26     #ifndef ONLINE_JUDGE
    27      //   freopen("input.txt","r",stdin);
    28     #endif
    29   //  std::ios::sync_with_stdio(false);
    30     while(~scanf("%lf",&s)){
    31         double L=0,R=sqrt(s/2.0/pi),mid1,mid2;
    32         while(R-L>eps){
    33             mid1=L+(R-L)/3;
    34             mid2=R-(R-L)/3;
    35             if(cal(mid1)>=cal(mid2)){
    36                 R=mid2;
    37             }
    38             else{
    39                 L=mid1;
    40             }
    41         }
    42         double l=s/pi/R-R;
    43         double h=sqrt(l*l-R*R);
    44         double v=pi*R*R*h/3.0;
    45         printf("%.2f
    %.2f
    %.2f
    ",v,h,R);
    46     }
    47 }
    View Code
  • 相关阅读:
    bootstrutp module 显示隐藏 模态框
    手机app传统邀请码安装与免邀请码安装区别,如何选择呢?
    好用的一些开源系统
    一个搞笑的招聘启事
    java和android及IOS对接RSA加密经验
    mysql大数据表改表结构方案
    android开发中监控android软件网络请求的软件Charles使用入门
    android IOC框架学习记录
    java分布式事务
    十八届三中全会的综合改革方案将涉及哪些内容?(转自知乎)
  • 原文地址:https://www.cnblogs.com/Fighting-sh/p/10463033.html
Copyright © 2011-2022 走看看