Expanding Rods
Time Limit: 1000MS   Memory Limit: 30000K
Total Submissions: 10187   Accepted: 2593

Description

When a thin rod of length L is heated n degrees, it expands to a new length L'=(1+n*C)*L, where C is the coefficient of heat expansion. 
When a thin rod is mounted on two solid walls and then heated, it expands and takes the shape of a circular segment, the original rod being the chord of the segment.

Your task is to compute the distance by which the center of the rod is displaced.

Input

The input contains multiple lines. Each line of input contains three non-negative numbers: the initial lenth of the rod in millimeters, the temperature change in degrees and the coefficient of heat expansion of the material. Input data guarantee that no rod expands by more than one half of its original length. The last line of input contains three negative numbers and it should not be processed.

Output

For each line of input, output one line with the displacement of the center of the rod in millimeters with 3 digits of precision. 

Sample Input

1000 100 0.0001
15000 10 0.00006
10 0 0.001
-1 -1 -1

Sample Output

61.329
225.020
0.000

Source

Waterloo local 2004.06.12

我们要求的是下图中的b,显然b的取值范围是[0,L/2]。对于每一个b,我们可以求出在已知弦L的情况下的半径R,从而可以求出此半径R和弦L下对应的圆弧的长度L0。经过与公式计算出来的L1进行对比,调整b的大小。经过观察,发现b越大,L0也就越大。所以如果L0>L1,应使b减小(right=mid-e),以减少L0。相反,当L0<L1的时候,应该让b增大(left=mid+e),以增大L0。

附注:求半径的方法是根据a,b,d,先求出h,然后求出R。接着根据圆心角和半径,求出圆弧的长度。

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath> using namespace std; const double eps=1e-; double l,l0,l00; double get00(double b)
{
double a=l/.;
double d=sqrt(a*a+b*b);
double h=d*a/b;
double R=sqrt(h*h+d*d)/.;
double alpha=atan(b/a);
return *alpha*R;
} int main()
{
double n,c;
while(cin>>l>>n>>c)
{
if(l<&&n<&&c<) break;
l0=(.+n*c)*l;
if(fabs(l0-l)<eps)
{
printf("0.000\n");
continue;
}
double low=,high=l/.,mid,ans;
while(low<high)
{
mid=(low+high)/.;
l00=get00(mid);
if(fabs(l00-l0)<eps)
{
ans=mid; break;
}
else if(l00>l0)
high=mid;
else
low=mid;
}
printf("%.3lf\n",ans);
}
return ;
}

POJ 1905 Expanding Rods的更多相关文章

  1. poj 1905 Expanding Rods(木杆的膨胀)【数学计算+二分枚举】

                                                                                                         ...

  2. POJ 1905 Expanding Rods(二分)

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

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

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

  4. POJ - 1905 Expanding Rods(二分+计算几何)

    http://poj.org/problem?id=1905 题意 一根两端固定在两面墙上的杆,受热后变弯曲.求前后两个状态的杆的中点位置的距离 分析 很明显需要推推公式. 由②的限制条件来二分角度, ...

  5. poj 1905 Expanding Rods (数学 计算方法 二分)

    题目链接 题意:将长度为L的棒子卡在墙壁之间.现在因为某种原因,木棒变长了,因为还在墙壁之间,所以弯成了一个弧度,现在求的是弧的最高处与木棒原先的地方的最大距离. 分析: 下面的分析是网上别人的分析: ...

  6. poj 1905 Expanding Rods 二分

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

  7. POJ 1905 Expanding Rods 木棍膨胀

    描述 当长度为L的一根细木棍的温度升高n度,它会膨胀到新的长度L'=(1+n*C)*L,其中C是热膨胀系数. 当一根细木棍被嵌在两堵墙之间被加热,它将膨胀形成弓形的弧,而这个弓形的弦恰好是未加热前木棍 ...

  8. POJ 1905 Expanding Rods (求直杆弯曲拱起的高度)(二分法,相交弦定理)

    Description When a thin rod of length L is heated n degrees, it expands to a new length L' = (1+n*C) ...

  9. POJ 1905 Expanding Rods( 二分搜索 )

    题意:一个钢棍在两面墙之间,它受热会膨胀成一个圆弧形物体,这个物体长 S = ( 1 + n * C ) * L,现在给出原长 L ,温度改变量 n ,和热膨胀系数 C,求膨胀后先后中点的高度差. 思 ...

随机推荐

  1. 加州大学伯克利分校Stat2.3x Inference 统计推断学习笔记: Section 4 Dependent Samples

    Stat2.3x Inference(统计推断)课程由加州大学伯克利分校(University of California, Berkeley)于2014年在edX平台讲授. PDF笔记下载(Acad ...

  2. JavaScript 写几个简单的知识点

    首先,还是用比较官方的文字描述来解释下JavaScript: JavaScript一种直译式脚本语言,是一种动态类型.弱类型.基于原型的语言,内置支持类型.它的解释器被称为JavaScript引擎,为 ...

  3. HDU 1598 find the most comfortable road(最小生成树之Kruskal)

    题目链接: 传送门 find the most comfortable road Time Limit: 1000MS     Memory Limit: 32768 K Description XX ...

  4. Nginx系列2之Nginx+php

    preface 公司所有的大多数业务都泡在LNMP平台上,所以对PHP+Nginx有点了解,那么就做个小小的总结吧. what's FastCGi FastCGI是一个可伸缩,高速的在HTTP ser ...

  5. 电脑开启wifi功能

    在Win7下,以管理员身份启动cmd,输入以下两条命令创建虚拟Wifi,并启动Wifi.其中ssid为WiFi的名字,key为密码.C:\>netsh wlan set hostednetwor ...

  6. 快捷键&小技巧&备忘录

    shift+鼠标滚轮:实现左右移动 alt+鼠标左键双击:打开属性 chrome中在F12下的Element中,可以先选中某一项,可以直接按住F2进行编辑 chrome中element的右下方我们可以 ...

  7. Yocto开发笔记之《Tip-bitbake常用命令》(QQ交流群:519230208)

    开了一个交流群,欢迎爱好者和开发者一起交流,转载请注明出处. QQ群:519230208,为避免广告骚扰,申请时请注明 “开发者” 字样 =============================== ...

  8. 命名实参和可选实参 Named and Optional Arguments

    1. 利用“命名实参”,您将能够为特定形参指定实参,方法是将实参与该形参的名称关联,而不是与形参在形参列表中的位置关联. static void Main(string[] args) { Conso ...

  9. WinForm------GridControl中通过判断单元格文字显示不同字体颜色或背景色

  10. js随笔,css和js禁止网页选择文本,table的class样式使得td的class样式失效,jquery获得元素坐标

    css使用user-select,user-select不是W3C标准,浏览器支持不完整:user-select有两个值,none用户不可以选择文本,text用户可以选择文本 body{-moz-us ...