Cylinder
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2374
思路:三分枚举。
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#define maxn 1000100
using namespace std;
const double eps=1e-;
const double pi=acos(-1.0); double w,h; double ok(double x,int flag)
{
double max1=;
double k=h;
double s=w;
double r=(x>s)?s:x;
double ss=pi*(r/)*(r/);
double ll=pi*r;
double c=k-x;
double r1=(k-x)>s?s:(k-x);
if(s>=ll&&flag==)
{
double v1=ss*c;
max1=max(max1,v1);
}
if(c>=ll&&flag==)
{
double v2=ss*s;
max1=max(max1,v2);
}
double s1=pi*(r1/)*(r1/);
double l1=pi*r1;
if(s>=l1&&flag==)
{
double v3=s1*x;
max1=max(v3,max1);
}
if(x>=l1&&flag==)
{
double v4=s1*s;
max1=max(max1,v4);
}
return max1;
} int main()
{
while(scanf("%lf%lf",&w,&h)!=EOF)
{
if(w==&&h==) break;
double l=,r=h;
double ans=,ans1=;
while(r-l>eps)
{
double mid1=(r+l)/;
double mid2=(l+mid1)/;
if(ok(mid1,)>=ok(mid2,))
{
ans=mid1;
l=mid2;
}
else
r=mid1;
}
l=,r=w;
while(r-l>eps)
{
double mid1=(r+l)/;
double mid2=(l+mid1)/;
if(ok(mid1,)>=ok(mid2,))
{
ans1=mid1;
l=mid2;
}
else
r=mid1;
}
printf("%.3lf\n",max(ok(ans,),ok(ans1,)));
}
return ;
}
Cylinder的更多相关文章
- ZOJ 3866 - Cylinder Candy
3866 - Cylinder Candy Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%lld & %llu ...
- Bleed Brake Master Cylinder with Intelligent Tester IT2
When the brake fluid level drops too low in the master cylinder reservoir, air bubbles can get caugh ...
- FusionWidgets Cylinder图
1.数据源 Cylinder.xml: <?xml version="1.0" encoding="UTF-8"?> <chart palet ...
- Cylinder Candy(积分+体积+表面积+旋转体)
Cylinder Candy Time Limit: 2 Seconds Memory Limit: 65536 KB Special Judge Edward the confectioner is ...
- Cylinder Candy(积分)
Cylinder Candy Time Limit: 2 Seconds Memory Limit: 65536 KB Special Judge Edward the confectioner is ...
- Track Cylinder
1 Track = 48 KB1 Cylinder = 720 KB so 1 Cylinder = 15 Tracks Read more: http://ibmmainframes.com/abo ...
- span-wise drag/lift forces of cylinder
span-wise drag/lift forces of cylinder SR Description: Dear Sir/Madam, I am trying to simulate a 3 ...
- Global UNIX file system cylinder group cache
A global cylinder group (CG) cache is stored in file server memory and shared by a plurality of file ...
- WPF 3D model - Sphere, Cone, and Cylinder
原文:WPF 3D model - Sphere, Cone, and Cylinder Extending Visual3D - Sphere, Cone, and Cylinder http: ...
- 以圆类 Circle 及立体图形类 Solid 为基础设计圆柱类 Cylinder
学习内容:以圆类 Circle 及立体图形类 Solid 为基础设计圆柱类 Cylinder 代码示例: import java.util.Scanner;class Point3{ private ...
随机推荐
- ios--绘图介绍
iOS–绘图介绍 绘制图像的三种方式 一. 子类化UIView,在drawRect:方法画图 执行方法时,系统会自行创建画布(CGContext),并且讲画布推到堆栈的栈顶位置 执行完毕后,系统会执行 ...
- IOS-tableViewCell重用机制
IOS-tableViewCell重用机制 首先介绍tableViewCell原生cell的使用和重用机制 使用dequeueReusableCellWithIdentifier方法,这个方法会从缓存 ...
- js 高阶函数 map reduce
map() var arr = [1,3,4]; function a(x){ return x*x; } //map可以将一个函数作为参数执行,将数组中的值,依次使用a函数处理: return ar ...
- ZOJ 3898 - Stean 积分
有一个陶罐,陶罐是由函数Y=2+cosX,截取x=Z1到x=Z2段后,形成的旋转体,陶罐只有底x=Z1,没有盖子. 问陶罐能乘多少的水(体积),以及它的表面积 体积还是比较好求的,直接用旋转体体积公式 ...
- 纯javascript代码编写计算器程序
今天来分享一下用纯javascript代码编写的一个计算器程序,很多行业都能用到这个程序,例如做装修预算.贷款利率等等. 首先来看一下完成后的效果: 具体代码如下:(关注我的博客,及时获取最新WEB前 ...
- JAVAWEB 生成excel文字在一格显示两位不变成#号
在用java生成excel的时候会发现这种问题, 如果是人家给的模板还好,如果不是模板,而是通过代码生成的话, 就需要进行处理了, 一个小单元格,如果是一位的话,如1-9显示没有问题,一旦是两位的话, ...
- maven jetty运行命令
1.先运行build.xml <?xml version="1.0" encoding="UTF-8"?> <project name=&qu ...
- Uncaught SecurityError: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported.
canvas绘制图片,由于浏览器的安全考虑,如果在使用canvas绘图的过程中,使用到了外域的图片资源,那么在toDataURL()时会抛出安全异常: Uncaught SecurityError: ...
- The performance between the 'normal' operation and the 'shift' operation.
First, I gonna post my test result with some code: //test the peformance of the <normal operation ...
- .NET 4.6
http://referencesource.microsoft.com/ DownLoad 下载原代码