POJ - 3737 - UmBasketella(三分)
2016-07-14 13:36
337 查看
UmBasketella
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
Sample Output
题意:给出一个圆锥的表面积(包含底面), 求该圆锥的最大体积,以及此时的底面半径和高
学习三分的第一道题目,最开始一看数学题已经晕了一半,公式不想推整个人都很颓。然后前天下午硬着头皮写了写,发现。。只要知道圆锥面积和体积公式就好了。。。没有什么需要推倒的公式orz.........
圆锥面积公式:
圆锥体积公式:v = π * r * r * h / 3
因底面半径为0或无穷大,该圆锥体积都为0,则函数近似于二次函数,所以三分
三分半径可根据面积公式得出高,然后计算体积即可。
最大初始值看题解有个很巧的方法:假设最开始侧面积与底面积重合的极限状态,则表面积是底面积的两倍
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 6554 | Accepted: 2550 |
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
题意:给出一个圆锥的表面积(包含底面), 求该圆锥的最大体积,以及此时的底面半径和高
学习三分的第一道题目,最开始一看数学题已经晕了一半,公式不想推整个人都很颓。然后前天下午硬着头皮写了写,发现。。只要知道圆锥面积和体积公式就好了。。。没有什么需要推倒的公式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; }
相关文章推荐
- JQ数组操作(定义一个数组,给数组赋值)
- JQ数组操作(定义一个数组,给数组赋值)
- Android 中View类DrawingCache的使用
- Android基础------图形和图像处理
- wordpress安装记录
- redmine 一键安装
- Android Studio编译报错“java.lang.OutOfMemoryError: GC overhead limit exceeded”
- Fiddler 设置断点,修改服务器响应消息
- 如何在CentOS安装Nginx?
- Android系统信息获取 之三:CPU信息获取
- 境外投资置业开始吃苦头 海外买房热面临退潮
- iOS 把你的UILabel多彩起来
- 搜索引擎的中文分词技术
- 构建一个透明的activity
- 搜索引擎基本工作原理
- 致还在成功路上探索的你
- android-destroyDrawingCache
- JQ选择HTML元素的方法
- 什么是行缓冲?printf输出的条件
- 连载:面向对象葵花宝典:思想、技巧与实践(8) - “接口” 详解