POJ1905-----Expanding Rods
2015-08-24 15:45
246 查看
[align=center]Expanding Rods[/align]
由公式正向二分;
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
Sample Output
Time Limit: 1000MS | Memory Limit: 30000K | |
Total Submissions: 13690 | Accepted: 3529 |
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 <iostream> #include<cstring> #include<cstdio> #include<queue> #include<stack> #include<algorithm> #include<cmath> using namespace std; const double esp=1e-5; int main() { double L,n,C,L1; while(cin>>L>>n>>C) { if(L==-1&&n==-1&&C==-1) break; L1=(1+n*C)*L; double low=0.0,high=0.5*L,mid,tmp,r; while(high-low>esp) { mid=(low+high)/2; r=(4*mid*mid+L*L)/(8*mid); tmp=2*r*asin(L/(2*r)); if(tmp<L1) { low=mid; } else { high=mid; } } printf("%.3f\n",mid); } return 0; }
相关文章推荐
- 【面试题之算法部分】二叉树的遍历
- 从3D打印成本来看3D打印的预测
- mahout安装测试
- Android微信SDK实现分享
- maven工程目录中各个文件的作用
- A Flexible New Technique for Camera Calibration
- HUST 1017 Exact cover (DLX模板题)
- Codeforces Round #317 (Div. 2) (572A Arrays,572B Order Book)
- iOS动画原理
- 【LeetCode】(162)Find Peak Element(Medium)
- Spiral Matrix
- 字典树
- [rxjs] Shares a single subscription -- publish()
- yum源修改为本地光盘镜像
- SpringMVC+Mysql实例详解
- 杭电3501Calculation 2 欧拉函数
- 谈谈3D打印成本之中的奥秘
- HDOJ 1407 测试你是否和LTC水平一样高
- _stdcall,_cdecl区别
- POJ 3281( 网络流 最大流 ISAP)