1137 - Expanding Rods

   PDF (English) Statistics Forum
Time Limit: 0.5 second(s) Memory Limit: 32 MB

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. That means you have to calculate h 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 millimeters L, the temperature change in degrees n and the coefficient of heat expansion of the material C. 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 than 10-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



SPECIAL THANKS: JANE ALAM JAN (DESCRIPTION, SOLUTION, DATASET, PICTURES)

思路:L‘ = p*r ——p为弧度

r = (L/2)/sin(p/2)

然后公式可以化为 (2×L) /L=(p)/sin(p/2);

然后右边求导可知道右边随p单调增,然后二分p即可。

 1 #include<stdio.h>
 2 #include<algorithm>
 3 #include<iostream>
 4 #include<string.h>
 5 #include<queue>
 6 #include<stack>
 7 #include<set>
 8 #include<math.h>
 9 using namespace std;
10 typedef long long LL;
11 double pi=acos(-1);
12 int main(void)
13 {
14     int i,j,k;
15     scanf("%d",&k);
16     int s;
17     double L ,n,c;
18     for(s=1; s<=k; s++)
19     {
20         scanf("%lf %lf %lf",&L,&n,&c);
21         double l=0;
22         double r=2*pi;
23         int ans=0;
24         double ll=(1+n*c)*L;
25         while(ans<=100)
26         {
27             double mid=(l+r)/2;
28             double ac=2*ll*sin(1.0*mid/2);
29             double ak=L*mid;
30             if(ac>=ak)
31             {
32                 l=mid;
33             }
34             else r=mid;
35             ans++;
36         }
37         double rr=(1.0*L/2)/(sin(1.0*r/2));
38         double hh=rr*cos(1.0*r/2);
39         double h=rr-hh;
40         printf("Case %d:",s);
41         printf(" %.6f\n",h);
42     }
43     return 0;
44 }
时间: 2024-11-05 13:31:43

1137 - Expanding Rods的相关文章

POJ 题目1905 Expanding Rods(二分,数学几何)

Expanding Rods Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 12827   Accepted: 3311 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. Whe

POJ1905 expanding rods 【水二分+谜之WA】

一道很水的题,就是不知道为什么wa,,, 其实小优那个精度控制循环控制二分的方法不算好,如果esp太小,会TLE,直接人工控制次数最好了 #include <cstdio> #include <cmath> #include <iostream> using namespace std; double getres(double r,double s,double l) { //cout<<(r-s/acos(1-l*l/(2.0*r*r)))<<

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

题目链接 题意:将长度为L的棒子卡在墙壁之间.现在因为某种原因,木棒变长了,因为还在墙壁之间,所以弯成了一个弧度,现在求的是弧的最高处与木棒原先的地方的最大距离. 分析: 下面的分析是网上别人的分析: 设弦长为L0(即原长),弧长为L1=(1+n*C)*l0,目标值为h,半径为R,弧所对圆心角为2θ(弧度制).可以得到以下方程组:圆的弧长公式:L1=2θR三角函数公式:L0=2*R*sinθ,变换得θ=arcsin(L0/(2*R))勾股定理:R^2=(R-h)^2+(0.5*L0)^2,变换得

UVA 10668 - Expanding Rods(数学+二分)

UVA 10668 - Expanding Rods 题目链接 题意:给定一个铁棒,如图中加热会变成一段圆弧,长度为L′=(1+nc)l,问这时和原来位置的高度之差 思路:画一下图可以很容易推出公式,设圆弧扇形部弧度r,那么可以计算出铁棒长度为lr/sin(r)这个公式在[0, pi/2]是单调递增的,所以可以用二分法去求解 要注意的一点是最后答案计算过程中带入mid,之前是带入x(二分的左边值),可实际上x是可能等于0的,而带入mid,由于是double型,所以mid实际上表示是一个非常趋近0

poj 1905 Expanding Rods(木杆的膨胀)【数学计算+二分枚举】

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. Whe

POJ 1905 Expanding Rods

Expanding Rods Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 12796   Accepted: 3299 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. Whe

poj1905 Expanding Rods 二分

Expanding Rods Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 11782   Accepted: 3063 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. Whe

POJ 1905(expanding rods)

[题意描述] 本题就是给定一个圆棒的热膨胀系数以及膨胀的温度,求最后变弯后中心点与原来中心点的距离. [思路分析] 几何+二分: 根据公式我们就可以利用二分进行查找了,当然二分是有技巧的,我们由于是double型数据,我们需要在设置循环条件时不能用high-low>0(会陷入系循环)而是需要设置精度esp(1e-5)写成high-low>esp就可以了. [AC代码] #include<iostream> #include<math.h> #include<iom

POJ 1905 Expanding Rods 浮点数二分

Expanding Rods Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 11145   Accepted: 2879 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. Whe