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. 查看cpu、内存和硬盘

    查看cpu cat /proc/cpuinfo 查看内存 top free -m 按兆为单位输出内存的已用,未用,总共等结果 cat /proc/meminfo |grep MemTotal 查看硬盘 ...

  2. xamarin android——数据绑定到控件(一)

    mono for android 中光标由ICursor 接口标识,该接口公开了操作结果数据集的所有方法.光标的使用非常消耗系统资源,所以不使用时应该光比光标.可以通过StartManagingCur ...

  3. [分享]好用的Markdown编辑器

  4. php常量运用注意

    多个文件引入,常量重复定义会失效,后者无法重复定义...靠

  5. canvas 的学习

    canvas 绘制直线的API有: 1.moveTo()起点坐标. 2.lineTo()绘制的直线 3. fillStyle以及 flii()是绘制实体的 4. strokeStyle 和stroke ...

  6. redis使用watch完成秒杀抢购功能:

    redis使用watch完成秒杀抢购功能: 使用redis中两个key完成秒杀抢购功能,mywatchkey用于存储抢购数量和mywatchlist用户存储抢购列表. 它的优点如下: 1. 首先选用内 ...

  7. js鼠标及对象坐标控制属性详细解析

    对js鼠标及对象坐标控制属性进行了详细的分析介绍.  offsetTop获取对象相对于版面或由 offsetParent 属性指定的父坐标的计算顶端位置. offsetLeft获取对象相对于版面或由 ...

  8. corsproxy

    安装完 node.js运行 npm install -g corsproxy安装完成 corsproxy

  9. iphone开发第二个程序

    此程序包括UIProgressView,UIButton, UIDatePicker,UIAlert,UILabel,NSTimer // //  HViewController.h //  Btn_ ...

  10. 怎样下载安装Firebug和使用Firebug

    Firebug是基于火狐(FireFox)浏览器的一个插件,它的作用是给Web页面开发者一个很好的测试前端页面代码的工具.所以深受网页开发者或网页布局爱好者的喜爱.像我们用DIV+CSS和html所写 ...