第一道三分题,有模板

#define eps 10e-6
double cal(){}//计算题目所需要的值
while(l+eps<r)
{
m1=l+(r-l)/3;
m2=r-(r-l)/3;
v1=cal(m1);
v2=cal(m2);
if(v1<v2)l=m1;
else r=m2;
}

  

感觉三分像是数学题,因为它求的是单峰极值的问题。

#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std; const double PI=3.141592653;
const double eps=1e-8; double S,RR,LL,m,mm; double cal(double r){
return sqrt(((r*S*S)-(2*PI*S*r*r))/9.0);
} int main(){
while(scanf("%lf",&S)!=EOF){
RR=S/PI;LL=0;
while(LL+eps<RR){
m=LL+(RR-LL)/3;
mm=RR-(RR-LL)/3;
if(cal(m)<cal(mm))
LL=m;
else RR=mm;
}
double v=cal(LL);
printf("%.2lf\n%.2lf\n%.2lf\n",v,v*3/(PI*LL),sqrt(LL));
}
return 0;
}

  

POJ 3737的更多相关文章

  1. POJ 3737/三分

    题目链接[http://poj.org/problem?id=3737] 题意:给出一个圆锥的表面积,求最大的体积,并输出最大体积的时候的圆锥的高度和底面积. 方法一: 根据定理:圆锥的表面积一定的时 ...

  2. [SinGuLaRiTy] 分治题目复习

    [SInGuLaRiTy-1025] Copyrights (c) SinGuLaRiTy 2017. All Rights Reserved. [POJ 1905] 棍的膨胀 (Expanding ...

  3. POJ 3301 Texas Trip (三分)

    题目链接 题意 : 给你若干个点,让你找最小的正方形覆盖这所有的点.输出面积. 思路 : 三分枚举正方形两对边的距离,然后求出最大,本题用的是旋转正方形,也可以用旋转点,即点的相对位置不变. 正方形从 ...

  4. poj 1700 Crossing River 过河问题。贪心

    Crossing River Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9887   Accepted: 3737 De ...

  5. POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理

    Halloween treats Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7644   Accepted: 2798 ...

  6. POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理

    Find a multiple Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7192   Accepted: 3138   ...

  7. POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治

    The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22286 ...

  8. POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法

    Flip Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 37427   Accepted: 16288 Descr ...

  9. POJ 3254. Corn Fields 状态压缩DP (入门级)

    Corn Fields Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9806   Accepted: 5185 Descr ...

随机推荐

  1. Leetcode:remove_element

    一.     题目 给定一个数组和一个值.删除当中和给定值相等的元素.返回得到的新数组长度 二.     分析 刚開始我以为仅仅须要返回最后的数组长度即可了呢! 后来WA了一次才知道还得把心数组构造好 ...

  2. ijkplayer详解AAA

    https://www.jianshu.com/p/c5d972ab0309 https://www.android-arsenal.com/details/1/530 https://stackov ...

  3. [JavaEE] Apache Maven 入门篇(下)

    http://www.oracle.com/technetwork/cn/community/java/apache-maven-getting-started-2-405568-zhs.html 作 ...

  4. jQuery不熟点总结

     jQuery 事件 1 .trigger() 方法触发被选元素的指定事件类型. 2 .delegate() 事件委派  1.不占内存2.可以给未来元素(后期动态添加的元素)添加事件. 2.  添加元 ...

  5. vcpkg错误分析方法

    最近在使用vcpkg时,经常会碰到CMake错误. 有些以前能编译通过的包, 过一段时间又不能编译错误了. 错误提示一般是CMake错误, 弄得很郁闷. 我采用以下步骤解决了问题: 分析错误 查看错误 ...

  6. Centos7中 文件大小排序

    centos7中根据文件大小排序以及jenkins配置每周删除一次jobs日志信息 https://blog.csdn.net/u013066244/article/details/70232050

  7. Codeforces Round #449

    960  asteri 1384     492 00:04 -1 892 01:33     960 PEPElotas 1384     488 00:06 896 00:26       960 ...

  8. spring IOC(DI)和AOP

    软件152谭智馗 IOC(Inversion of Control,控制倒转)Ioc意味着将你设计好的对象交给容器控制,而不是传统的在你的对象内部直接控制. DI—Dependency Injecti ...

  9. 使用光盘作为yum源安装ifconfig等网络命令

    # mkdir -p /mnt/cdrom# 如果是光驱:mount -t iso9660 /dev/cdrom /mnt/cdrom/# 如果是ISO:mount -o loop /usr/loca ...

  10. UWP App Services in Windows 10

    1.AppServices in Universal Windows Platform(UWP) UWP 应用服务可以提供给另一个UWP应用.在Win10系统中,一个应用服务当作应用的一个方法和机制来 ...