Expanding Rods
Time Limit: 1000MS   Memory Limit: 30000K
Total Submissions: 13516   Accepted: 3484

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 题目:可以这样理解,给你一根木杆,夹在某物体之间。现在木杆会受热膨胀,膨胀增长,在两端物体的挤压下就会变弯曲,如上图所示。
从一根直的木杆变到弯曲的木杆,两种状态下,木杆中间位置的高度差是多少?

解法全在上面的图片中! 代码:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <iostream>
#include <string>
#include <stack>
#include <algorithm>
#define eps 1e-5 using namespace std; int main()
{
// L'=(1+n*C)*L
double L, n, c;
while(scanf("%lf %lf %lf", &L, &n, &c)!=EOF)
{
if(L<0 && n<0 && c<0) break;
double low=0.0;
double high=0.5*L;
double mid;
double s=(1.0+n*c)*L;
double R; while(high-low>eps){
mid=(low+high)/2.0;
R = (4*mid*mid+L*L)/(8*mid);//化简成一次除法 减小精度误差
if(2*R*asin(L/(2*R)) < s)
low=mid;
else
high=mid;
}
printf("%.3lf\n",mid);
}
return 0;
}
												

poj 1905 Expanding Rods(木杆的膨胀)【数学计算+二分枚举】的更多相关文章

  1. POJ 1905 Expanding Rods

                           Expanding Rods Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 1 ...

  2. POJ 1905 Expanding Rods(二分)

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

  3. POJ 1905 Expanding Rods 木棍膨胀

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

  4. 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) ...

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

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

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

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

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

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

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

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

  9. poj 1905 Expanding Rods 二分

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

随机推荐

  1. MFC中调用chm帮助文档(使用相对路径)

    主要就一句话: ShellExecute(NULL,L"Open",path,NULL,NULL,SW_SHOWMAXIMIZED); 常用的显示方式是SW_SHOWNORMAL和 ...

  2. hdu 2460(tarjan求边双连通分量+LCA)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2460 思路:题目的意思是要求在原图中加边后桥的数量,首先我们可以通过Tarjan求边双连通分量,对于边 ...

  3. java的一些问题

    1. 判断是否是奇数: public static boolean isOdd(int i) { return i %2 != 0 ; } 2. System.out.println(2.0 - 1. ...

  4. Android无线测试之—UiAutomator UiSelector API介绍之二

    Android的布局与组件及组件属性介绍 一.布局: 1)线性布局:控价在线性方向上一次排列 2)表格布局:向表格一样有标准的行和列 3)相对布局:通过相对定位的方式让控件出现在布局的任何位置 4)帧 ...

  5. iPhone程序中的加密处理

    本文转载至 http://blog.csdn.net/zaitianaoxiang/article/details/6650478     原文链接 : http://www.yifeiyang.ne ...

  6. 导出大量数据到excel表

    set_time_limit(0);error_reporting(0); // 输出Excel文件头,可把user.csv换成你要的文件名header('Content-Type: applicat ...

  7. Error: member names cannot be the same as their enclosing type

    在编译的时候会遇到如下问题:member names cannot be the same as their enclosing type 原因:方法名和类名不能一样,如果一样就是一个构造函数.而构造 ...

  8. SSL逐渐演变到TLS

    w https://zh.wikipedia.org/wiki/超文本传输安全协议

  9. JavaScript数据结构与算法-列表练习

    实现列表类 // 列表类 function List () { this.listSize = 0; // 列表的元素个数 this.pos = 0; // 列表的当前位置 this.dataStor ...

  10. SqlProfiler的替代品-ExpressProfiler

    可以用来跟踪执行的sql语句.安装SqlServer之后SqlServerManagementStudio自带一个SqlProfiler,但是如果安装的SqlExpress,那就没有了. 项目的主页在 ...