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
三分模板题
#include<cstdio>
#include<cmath>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 1000006
#define eps 1e-8
#define pi acos(-1.0)
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef unsigned long long ull; double s; double cal(double r){
double l=s/pi/r-r;
double h=sqrt(l*l-r*r);
double v=pi*r*r*h/3.0;
return v;
} int main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
#endif
// std::ios::sync_with_stdio(false);
while(~scanf("%lf",&s)){
double L=,R=sqrt(s/2.0/pi),mid1,mid2;
while(R-L>eps){
mid1=L+(R-L)/;
mid2=R-(R-L)/;
if(cal(mid1)>=cal(mid2)){
R=mid2;
}
else{
L=mid1;
}
}
double l=s/pi/R-R;
double h=sqrt(l*l-R*R);
double v=pi*R*R*h/3.0;
printf("%.2f\n%.2f\n%.2f\n",v,h,R);
}
}
UmBasketella的更多相关文章
- poj3737 UmBasketella 真正的三分
之前用二分写三分的板子...现在正式写一个三分,但是也不难,就是把区间分为三段就行了.求二次函数的峰值,每次取大的区间就行了. 题干: 最近几天,人们总是设计出多功能的新东西.例如,您不仅可以使用手机 ...
- POJ3737 UmBasketella
嘟嘟嘟 一道三分入门题. 参考二分,三分就是每一次把区间分成三段,然后舍弃一段,不断缩小范围直到一个点. 一般用于求单峰函数的最值问题. 这道题发现V和r成一次函数的关系,因此三分r. 下面给出三分板 ...
- [SinGuLaRiTy] 分治题目复习
[SInGuLaRiTy-1025] Copyrights (c) SinGuLaRiTy 2017. All Rights Reserved. [POJ 1905] 棍的膨胀 (Expanding ...
随机推荐
- 微信小程序插件 - 开发教程
昨天(2018.3.13),微信小程序发布了重大功能更新,支持插件的使用和开发,个人预计,不超过2个月,优质服务的插件将会如雨后春笋般涌现. 这篇文章,我将会带大家,从0开始,学习如何开发和使用插件. ...
- day26-保护属性
如果有一个对象,当需要对其进行修改属性时,有2种方法 1.对象名.属性名 = 数据 --->直接修改 2.对象名.方法名() --->间接修改 为了更好的保护属性安全,即不能随意修改,一般 ...
- RocketMQ服务搭建_1
rocketmq是阿里研发,并贡献给Apache的一款分布式消息中间件. RcoketMQ 是一款低延迟.高可靠.可伸缩.易于使用的消息中间件. ACE环境:(Adapted communicatio ...
- BBS-基于用户认证组建和Ajax实现登陆验证
功能1: 基于用户认证组件和Ajax实现登录验证(图片验证码) 总结: 1 一次请求伴随多次请求 2 PIL 3 session存储 4 验证码刷新 步骤: 1.配置静态文件夹 settings.py ...
- subsets 回溯 给定集合,枚举子集。元素不重复
这个回溯感觉掌握的有些熟练了. 两种方式,递归和循环. 感觉就是套框架了. /** * Return an array of arrays of size *returnSize. * The siz ...
- centos7,进程最大打开文件数 too many open files错误
遇到一问题,tomcat最近发生几次异常,查看日志,发现一直报 too many open files,熟悉的同学都知道这是用户打开文件数过多导致的, 再用命令ls /proc/20861/fd/ | ...
- shell字符串基本操作
shell脚本中一切变量皆字符串,所以必须掌握字符串的常用处理方法.比如获取字符串长度.获取字符串指定位置字符.替换字符串中的指定字符或者删除某些字符等操作. 1.字符串操作列表 (1)var=val ...
- 深入jUI(DWZ)
-----------------------------------------------------------------------------主页面index.html <html& ...
- jQuery中事情的动态绑定
在jQuery的开发过程中,我们往往需要处理各种事件,例如click(),hover()等.在jQuery的API中,我们可以使用不同的方法来将这些事件绑定到特定的元素中.今天这篇文章中,我们将要介绍 ...
- 2.Servlet基础.md
目录 1.定义 2.特点 3.手动编写一个Servlet 3.1创建一个Servlet类 3.2找到编写类的class文件,将这个类的整个包拷贝到一个web应用中的WEB-INF/classes目录下 ...