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. 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
3
1000 100 0.0001
150 10 0.00006
10 0 0.001
Sample Output
Case 1: 61.3289915
Case 2: 2.2502024857
Case 3: 0
数学知识:</div><div>假设要求的是mid;有mid推出弧长,然后与真实的比较。</div><div>(r-mid)*(r-mid)+l*l/4=r*r;</div></div>
#include<cstdio>
#include<cmath>
double L, N, C, S;
bool check(double mid)
{
double ans = 2 * asin((L / 2) / ((L*L + 4 * mid*mid) / (8 * mid)))*((L*L + 4 * mid*mid) / (8 * mid));
return ans >= S;
}
int t;
int main()
{
double left, right, mid;
scanf("%d",&t);
int k=0;
while (t--)
{
scanf("%lf%lf%lf",&L,&C,&N);
if (L + N + C < 0 )
break;
S = (1 + N*C)*L;
left = 0.0;
right = L/2;
while (right - left > 1e-7)
{
mid = (right + left) / 2;
if (check(mid))
{
right = mid-1e-7;
}
else
{
left = mid+1e-7;
}
}
printf("Case %d:",++k);
printf(" %.6lf\n",mid);
}
return 0;
}
本文介绍了一种计算受热膨胀后薄杆中心位移的方法。通过输入初始长度、温度变化及材料膨胀系数,采用数学逼近算法求解圆弧段高度。适用于解决薄杆两端固定并受热膨胀的实际问题。
370

被折叠的 条评论
为什么被折叠?



