GDUT_ winter training solution to a problem report _ topic I_J personal problem solution to a problem report

GDUT_ winter training solution to a problem report _ topic I_J personal problem solution to a problem report

J title: binary floating-point number

topic:

When the length L n of the thin rod is heated, it expands to a new length L '= (1 + n * C) * L, where C is the coefficient of thermal expansion.

When a thin rod is mounted on two solid walls, and then heated, it will expand, forming a circular segment, the chord of the segment of the original bar is chord segments.

Your task is to calculate the distance from the center of the rod displacement.

Entry

Input contain multiple lines. Each row contains three non-negative input: the initial length of the rod (mm), temperature (deg) and the coefficient of thermal expansion. The input data to ensure that no more than half of the expansion rod of its original length. The last line contains three negative input, it should not be treated.

Export

For each line of input, output line, wherein the center comprises a rod displacement in millimeters, and the precision of 3 digits.

From the point of view on the topic, L is a long stick, then there will be a heated L`, then ask him high arch height, we can easily come to a knowledge of physics, this arc, after all, is a given arc tangent along two start everywhere by the force balance;

Problem is reduced to: find a chord length L, corresponding to the arc length of the sector L`, R- find its center perpendicular to the chord length.

If this problem directly we do not seem to find an effective way, only a lot of expression, but to achieve verify whether the answer is correct it can be done, we use the h-half results:
each corresponds to a R h and the sector angle Alpha:
the Code:

using namespace std;
double L,N,C;

int main()
{
	while(~scanf("%lf %lf %lf",&L,&N,&C) && L>=0 && N>=0 && C>=0)
	{
		//h的范围:0——L/2;
		double left=0,right=L/2;
		double L1=(1+N*C)*L;
		while(right-left>=1e-8)
		{
			double mid=left+(right-left)/2;

			double R=mid/2+L*L/8/mid;
			double Alpha=asin(L/(R*2));
			if(L1>2.0*R*Alpha)
			{//h小了,应该往上取
				left=mid;
			}
			else right=mid;

		}
		printf("%.3f\n",left);
	}
	return 0;

}
Released eight original articles · won praise 0 · Views 116

Guess you like

Origin blog.csdn.net/DevourPower/article/details/103952913