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. 5、easyUI-菜单与按钮

    列出源码:求解 <html> <head> <meta http-equiv="Content-Type" content="text/ht ...

  2. windows下编译boost for android

    env: windows xp 32 bit mingw official  NDK 1. 下载源代码    地址是 :http://sourceforge.net/projects/boost/fi ...

  3. 导出大量数据到excel表

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

  4. [HAOI2012] 容易题[母函数]

    794. [HAOI2012] 容易题 ★★☆   输入文件:easy.in   输出文件:easy.out   简单对比时间限制:1 s   内存限制:128 MB 秒 输入:easy.in 输出: ...

  5. 【BZOJ4771】七彩树 主席树+树链的并

    [BZOJ4771]七彩树 Description 给定一棵n个点的有根树,编号依次为1到n,其中1号点是根节点.每个节点都被染上了某一种颜色,其中第i个节点的颜色为c[i].如果c[i]=c[j], ...

  6. 七、Dockerfile案例三(Mysql安装)

    七.Dockerfile案例三(Mysql安装) *特别提醒:新版的mysql:5.7数据库下的user表中已经没有Password字段了(5.5的user表还有) 一.查看docker hub上的版 ...

  7. CSS3选择器:nth-child与:nth-of-type区别

    一.:nth-child 1.1 说明 :nth-child(n)选择器匹配属于其父元素的第N个子元素,不论元素的类型.n可以是数字.关键词或公式. 注意:如果第N个子元素与选择的元素类型不同则样式无 ...

  8. js,jquery和dojo操作dom

    最近想学习arcgis javascript api,拦路虎就是dojo,为了便于理解dojo,在学习dojo的同时参考原生js和jquery,下午学习了下dom操作,mark下! 一.获取元素 js ...

  9. MySQL中事务的分类

    从事务理论的角度来看,可以把事务分为以下几种类型 扁平事务(Flat Transactions) 带有保存点的扁平事务(Flat Transactions with Savepoints) 链事务(C ...

  10. Python利用subprocess起进程

    from multiprocessing import Process, Pool import time import subprocess def task(msg): print 'hello, ...