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. go反射----4构建

    声明:文章内容取自雨痕老师<Go语言学习笔记> 反射库提供了内置函数make和new的对应操作,其中最有意思的就是MakeFunc.可用它实现通用模板,适应不同数据类型. package ...

  2. TCP和UDP 协议发送数据包的大小

    在进行UDP编程的时候,我们最容易想到的问题就是,一次发送多少bytes好? 当然,这个没有唯一答案,相对于不同的系统,不同的要求,其得到的答案是不一样的,这里仅对像ICQ一类的发送聊天消息的情况作分 ...

  3. 如何使用NSOperations和NSOperationQueues

    原文地址: http://www.raywenderlich.com/19788/how-to-use-nsoperations-and-nsoperationqueues 本文由 大侠自来也(泰然教 ...

  4. IOS7 UI Transition Guide 状态栏 statusbar

    本文转载至 http://blog.csdn.net/linzhiji/article/details/12233387 Redesign Your App for iOS 7 之 页面布局 iOS7 ...

  5. 玩点不同之CSS的BEM规范

    1.BEM引入背景 因为项目的业务逻辑发生重大变化,所以原来大半年的开发周期里做的事情基本上变成无用功.但是公司的项目上线时间依旧没有改变.剩下的时间只有区区的两个月,要做的功能是有社区+电商+核心业 ...

  6. 学生成绩管理系统【c】

    #include<stdio.h> #include<stdlib.h> #include<string.h> #include<conio.h> #d ...

  7. FFF at Valentine(强连通分量缩点+拓扑排序)

    FFF at Valentine Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) ...

  8. Python3.6全栈开发实例[018]

    18.车牌区域划分, 现给出以下车牌.根据车牌的信息, 分析出各省的车牌持有量.(升级题) result = {} for car in cars: location = locals[car[0]] ...

  9. 解决vsftp &quot;上传 553 Could not create file&quot;

    这个问题仅仅要:       1. setsebool -P ftpd_disable_trans 1       2. service vsftpd restart       太纠结了,呵呵

  10. MySQL 5.6 死锁演示 及 日志分析

    1.  表结构 CREATE TABLE dead_update ( a ) ', PRIMARY KEY (a) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; ), ...