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 ...
随机推荐
- JS 异步分段上传文件
为了解决大文件上传 (PHP上传最大限制2GB) 同时为了解决文件上传是对服务器造成的压力 可以通过分段上传解决这个问题,这得益于HTML5开发的file API 前台代码: 引用了进度条插件myPr ...
- OV7670配置和调试小结
先上一下OV7670的框架图 OV7670常用寄存器设置说明 直接看OV7670 Implementation Guide (V1.0)等 资料我已经上传了 https://files.cnblogs ...
- 缓存框架有使用过哪些?memcache和redis有什么区别?项目中,怎么去选择?
缓存有:ehcache,memcache和redis等 区别: 1. Redis和Memcache都是将数据存放在内存中,都是内存数据库.不过memcache还可用于缓存其他东西,例如图片.视频等等. ...
- List去重问题引出来的hashCode和equals方法
一.List 里面是基本类型的去重问题 import java.util.ArrayList; import java.util.HashSet; import java.util.List; imp ...
- HTML页面禁用Enter键自动提交表单
今天在开发页面时,遇到一个小BUG,,如下图 在页面的文本框获取焦点之后,再按键盘上的Enter键,页面form就会自动提交.如下是页面禁止Enter自动提交代码: document.onkeydow ...
- css-选择器性能
ID选择器 比如#header 类选择器 比如.promo 元素选择器 比如 div 兄弟选择器 比如 h2 + p 子选择器 比如 li > ul 后代选择器 比如 ul a 7. 通用选择器 ...
- vue:监听数据
1:普通的监听: data () { return { watchNum:1, } }, watch: { watchNum(newValue, oldValue) { console.log(old ...
- UE 不生成.bak文件
.bak文件是UE处理文件时自动备份的文件,可以取消备份这样就不会生成.bak文件了 菜单:高级-设置-文件处理-备份 应用和确定
- 剑指offer例题——裴波那契数列
编程题:大家都知道裴波那契数列,现在要求输入一个整数n,请你输出裴波那契数列的第n项(从0开始,第0项为0).n<=39 public class Solution { public int F ...
- mybatis中事务简单使用
一步: 事务只用在service层方法上加 @Transactional(propagation = Propagation.REQUIRED) :发现如果没有它,增加执行-->1/ ...