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 ...
随机推荐
- Oracle查询表结果添加到另一张表中
转自:https://blog.csdn.net/lx870576109/article/details/78336695 把每一个知识点进行积累:Oracle数据库中将查询一张表的结果添加到另一张表 ...
- mybatis 异常和注意
1. Could not set parameters for mapping like语句出错,因将%%写入到mapper.xml中导致,将%%随同参数一并传入. 例:String userNam ...
- 子类中的成员函数覆盖父类(name hiding)
只要子类中出现了和父类中同名的函数,父类中的所有这个名字的函数,就被屏蔽了. 静态函数成员也是如此?经过代码验证,确实如此. #include <iostream> using names ...
- Crash 文件调试
Xcode目录下执行 find . -name symbolicatecrash 找到symbolicatecrash位置,将其拷贝到debug用的文件夹下 执行命令 export DEVELOPER ...
- URL记录
http://orchome.com/5https://www.cnblogs.com/haozhengfei/p/2192231596ceb2ac4c22294dbd25a1ca.htmlhttps ...
- 6.5 Shell 算术计算
6.5 Shell Arithmetic shell允许在其内计算表达式,可以通过以下方式使用:((中,let和带-i选项的declare命令中. 只能计算固定长度的整数,而且不会检查溢出,除0可以捕 ...
- redis集群报错:(error) MOVED 11469 192.168.163.249:7002
应该是你没有启动集群模式(即缺少了那个"-c"): redis-cli -c -h yourhost -p yourpost
- MTIM(中间人攻击)
所谓的MITM攻击就是通过拦截正常的网络通信数据,并进行数据篡改和嗅探,而通信的双方却毫不知情. 信息篡改 当主机A.和主机B通信时,都由主机C来为其“转发”,如图一,而A.B之间并没有真正意思上的直 ...
- android如何快速查看APK包名和activity
一.通过ADB命令 1.dos进入 2.输入adb shell登录 3.输入dumpsys package | grep eggs(过滤相关包名) 二.通过日志查看包名() 1.连接设备 2.cmd命 ...
- 用Delphi改变图片的像素,即大小
我给你讲一种非常简单的方法: 第一步:在窗体上放上image1和image2两个图片控件.再放一个Button按钮控件. 第二步:在image1的Picture属性中载入一张JPG或者BMP图片.而i ...