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 ...
随机推荐
- PHP读取文件头(2字节)判断文件类型(转)
看到此标题或许你会说是否是多此一举,直接判断扩展名不就知道文件类型了吗,但是扩展名很容易伪造,这样就绕过了判断.大部分的文件都会将一个特殊的数字或字符存放在文件的特定位置里(开始处的2个字节) /** ...
- android 12 click事件的不同实现方式
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layo ...
- VS2012减负:加快启动速度,减少编辑卡壳
我公司的笔记本配置如下: CPU:i5-3210M @ 2.50 GHz 2.50 GHz mem: 4.00 GB OS: 64bit Win7 用VS2012编译Cocos2d-X项目时非常的卡. ...
- SQL Server2005 表分区三步曲(zz)
前言 SQL Server 2005开始支持表分区,这种技术允许所有的表分区都保存在同一台服务器上.每一个表分区都和在某个文件 组(filegroup)中的单个文件关联.同样的一个文件/文件组可以容纳 ...
- 彻底删除mysql的方法(有隐藏文件)
1.建议使用360进行卸载,可以彻底卸载软件 2.360会提醒删除注册表 3.这个隐藏文件要删除掉 在 C:\Documents and Settings\ 路径下搜索 MySQL 文件夹(默认隐藏的 ...
- CSS3 box-sizing 属性
定义和用法 box-sizing 属性允许您以特定的方式定义匹配某个区域的特定元素. 例如,假如您需要并排放置两个带边框的框,可通过将 box-sizing 设置为 "border-box& ...
- 认识k_BackingField【转】
事情从Json的序列化和反序列化说起. 在C#2.0的项目中,以前经常使用Json.Net实现序列化和反序列化.后来从c#3.0中开始使用新增的DataContractJsonSerializer进行 ...
- TabHost理解与使用
一.继承关系 java.lang.Object ↳ android.view.View ↳ android.view.ViewGroup ↳ android.widget.FrameLayout ↳ ...
- 关于jquery的 $("form").serialize()和 new FormData表单序列化
$("form").serialize()和 new FormData($('#uploadForm')[0])都是序列化表单,实现表单的异步提交,但是二者有区别 首先,前者,只能 ...
- C#获取类中所有方法
var t = typeof(HomeController); //获取所有方法 System.Reflection.MethodInfo[] methods = t.GetMethods(); // ...