http://poj.org/problem?id=1905

题意 :在两堵实心墙中间有一根杆,长度为L,然后给它加热,温度是n,则两墙之间的杆会弯曲,长度会变为L'=(1+n*C)*L,求前后两个状态杆的中心位置的距离

思路 :一部分几何加上最主要的二分 。这个我发现小优姐写的特别好,分析的也很完美,我就不再多解释了,发一下链接吧http://blog.csdn.net/lyy289065406/article/details/6648562

#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std ;
const double eps = 1e- ;
int main()
{
double l,tem,c ;
while(scanf("%lf %lf %lf",&l,&tem,&c)!=EOF)
{
if(l == -&&tem == -&&c == -)
break ;
double s = (+tem*c)*l ;
double low = 0.0 ;
double high = 0.5*l ;
double mid ;
while(high - low > eps)
{
mid = (low+high)/;
double r = (*mid*mid+l*l)/(*mid) ;
if((*r*asin(l/(*r))) < s)
low = mid ;
else high = mid ;
}
printf("%.3lf\n",mid) ;
}
return ;
}

对于代码中对最小精度的规定,不能太小,若是太小的话,循环次数容易增多,会超时,一般到1e-10就是TLE,不过5到8都是0ms过的,所以要注意以下,还有一个要注意的点是二分循环不能直接用<=这样的话会陷入死循环,因为都是double类型的。

POJ1905Expanding Rods(二分)的更多相关文章

  1. Expanding Rods(二分POJ1905)

    Expanding Rods Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 13688   Accepted: 3527 D ...

  2. 二分法 (UVA10668 Expanding Rods)(二分+几何)

    转载请注明出处:優YoU http://user.qzone.qq.com/289065406/blog/1301845324 大致题意: 一根两端固定在两面墙上的杆 受热弯曲后变弯曲.求前后两个状态 ...

  3. Expanding Rods(二分)

    Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 10287   Accepted: 2615 Description When ...

  4. POJ 1905 Expanding Rods 二分答案几何

    题目:http://poj.org/problem?id=1905 恶心死了,POJ的输出一会要lf,一会要f,而且精度1e-13才过,1e-12都不行,错了一万遍终于对了. #include < ...

  5. poj 1905 Expanding Rods 二分

    /** 题解晚上写 **/ #include <iostream> #include <math.h> #include <algorithm> #include ...

  6. UVA 10668 - Expanding Rods(数学+二分)

    UVA 10668 - Expanding Rods 题目链接 题意:给定一个铁棒,如图中加热会变成一段圆弧,长度为L′=(1+nc)l,问这时和原来位置的高度之差 思路:画一下图能够非常easy推出 ...

  7. POJ 1905:Expanding Rods 求函数的二分

    Expanding Rods Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 13780   Accepted: 3563 D ...

  8. D - Expanding Rods POJ - 1905(二分)

    D - Expanding Rods POJ - 1905 When a thin rod of length L is heated n degrees, it expands to a new l ...

  9. POJ 1905 Expanding Rods(二分)

    Expanding Rods Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 20224 Accepted: 5412 Descr ...

随机推荐

  1. office2013发布博客

    0, 喜欢用world记笔记,并查上一些配图.但是再想重新发到博客上,图片不得不重新上传十分蛋疼. world直接发布博客功能太棒了,直接绑定账号和url就可以发送了,爽YY!!! 1,新建一个博客文 ...

  2. 怎样把SEL放进NSArray里

    我的技术博客经常被流氓网站恶意爬取转载.请移步原文:http://www.cnblogs.com/hamhog/p/3805270.html,享受整齐的排版.有效的链接.正确的代码缩进.更好的阅读体验 ...

  3. Adobe Photoshop CS4 Extended CS4 激活序列号

    Adobe Photoshop CS4 Extended CS4 激活序列号(SN):1330-1779-4488-2103-6954-09161330-1170-1002-7856-5023-077 ...

  4. ARC forbids explicit message send of release

    http://blog.sina.com.cn/s/blog_7b9d64af01019rqt.html

  5. gets--vs--fgets

    gets  fget的区别 这两个函数都能从标准的输入流中读取信息,比如从键盘中输入信息,但是有些区别.   使用gets当输入的字符多于预定个数时候,会造成溢出,程序报错. int main(int ...

  6. linux系统文件属性及企业精典故障案例

    linux系统文件属性: [root@nginx_back ~]# stat keepalived-1.2.7.tar.gz 查看文件属性 File: "keepalived-1.2.7.t ...

  7. Python试卷

    3.写一个函数,计算一个给定的日期是该年的第几天. def getday(self,y=None,m=None,d=None): date = datetime(y,m,d) days = date. ...

  8. 《WPF程序设计指南》读书笔记——第2章 基本画刷

    1.Color结构 using System; using System.Windows; using System.Windows.Input; using System.Windows.Media ...

  9. N皇后问题2

    Description Examine the  checkerboard below and note that the six checkers are arranged on the board ...

  10. MySQL创建数据库[保存mojo格式的数据库]已经常用的utf8格式数据库

    一.创建最新编码utf8mb4格式的库: CREATE DATABASE IF NOT EXISTS yourdbname CHARACTER SET utf8mb4 COLLATE utf8mb4_ ...