【LightOJ】1137 - Expanding Rods(二分 & 几何)
来源:互联网 发布:淘宝买家恶意拍下付款 编辑:程序博客网 时间:2024/05/15 23:52
点击打开题目
When a thin rod of length L is heated n degrees, it expands to a new lengthL' = (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. That means you have to calculateh as in the picture.
Input
Input starts with an integer T (≤ 20), denoting the number of test cases.
Each case contains three non-negative real numbers: the initial length of the rod in millimetersL, the temperature change in degrees n and the coefficient of heat expansion of the materialC. Input data guarantee that no rod expands by more than one half of its original length. All the numbers will be between 0 and 1000 and there can be at most 5 digits after the decimal point.
Output
For each case, print the case number and the displacement of the center of the rod in single line. Errors less than10-6 will be ignored.
Sample Input
Output for Sample Input
3
1000 100 0.0001
150 10 0.00006
10 0 0.001
Case 1: 61.3289915
Case 2: 2.2502024857
Case 3: 0
主要是几何分析,这里我就不一点点画图了,给一个链接,分析的就很好:点击打开链接
代码如下:
#include <cstdio>#include <cmath>int main(){double left,right,mid;double l,n,s,c;double r;int Case = 1;int u;scanf ("%d",&u);while (u--){scanf ("%lf %lf %lf",&l,&n,&c);printf ("Case %d: ",Case++);s = (1.0+n*c)*l;left = 0;right = l / 2.0;while (right - left > 1e-8){mid = (right + left) / 2.0;r = (l*l + 4*mid*mid) / (8*mid);double t = asin(l/2/r);if (t * r * 2.0 < s)left = mid;elseright = mid;}printf ("%.6lf\n",left);}return 0;}
- 【LightOJ】1137 - Expanding Rods(二分 & 几何)
- lightoj 1137 Expanding Rods | 二分+几何
- Expanding Rods(二分+几何)
- LightOJ 1137 Expanding Rods(加热变化的路,二分)
- Lightoj 1137 Expanding Rods (二分,数学)
- Light OJ:1137 Expanding Rods(二分+几何数学)
- 【Light-oj】-Expanding Rods(二分&几何)
- 【二分+几何】F - Expanding Rods
- poj1905 Expanding Rods(二分+几何)
- POJ 题目1905 Expanding Rods(二分,数学几何)
- Pku oj 1905 Expanding Rods(简单几何加二分)
- POJ1905 Expanding Rods(计算几何推公式+二分)
- POJ 1905 Expanding Rods (二分+计算几何)
- POJ 1905 Expanding Rods(几何+二分)
- POJ 1905-Expanding Rods(二分+计算几何)
- POJ - 1905-Expanding Rods-数论-二分&几何
- POJ 1905 Expanding Rods 几何加二分
- POJ 1905 Expanding Rods几何题,二分
- 如何用Linux的命令正确识别cpu的个数和核数
- python 报错
- 【HDU】-4004-The Frog's Games(二分,难)
- 121. Best Time to Buy and Sell Stock
- JavaScript ---- 懒加载demo
- 【LightOJ】1137 - Expanding Rods(二分 & 几何)
- javaweb学习总结(六)——Servlet开发(二)
- eclipse 断点调试
- 【linux c】c语言关键字作用及注意事项_学习笔记_013
- 打造Android微信朋友圈下拉刷新控件
- UVA 489 Hangman Judge【刽子手】
- redis3.0.0 集群安装详细步骤
- 杭电ACM 1201 18岁生日
- Maven 国内settings设置