Expanding Rods解题报告

原创 2012年03月25日 20:28:53

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<cmath>
using namespace std;
const double ep=1e-12;
const double pi=acos(0.0);
int main()
{
	double n,c,L;
	while(scanf("%lf%lf%lf",&L,&n,&c)!=EOF)
	{
		if(L==-1&&n==-1&&c==-1)
			break;
		else
		{ 
			double a;
			a=(1+n*c)*L;   //L'的公式。
			double low=0,high=pi,mia;
			while(low+ep<high)  //精确范围。
			{
				mia=(low+high)/2.0;  //(0,PI)中二分查找。
				if(sin(mia)/mia>L/a)  
				{
					low=mia;
				}
				else
					high=mia;
			}
			printf("%.3lf\n",(1-cos(high))*L/(2*sin(high)));
		}
	}
	return 0;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

POJ-1905 Expanding Rods 解题报告

Description When a thin rod of length L is heated n degrees, it expands to a new length L'=(1+n*C...

I - Expanding Rods解题报告(黄杰)

I - Expanding Rods Time Limit:1000MS     Memory Limit:30000KB     64bit IO Format:%I64d &...

浙大 ACM 解题报告

  • 2015-12-30 21:51
  • 835KB
  • 下载

poj-1905 Expanding Rods

Description When a thin rod of length L is heated n degrees, it expands to a new length L'=(1+n*C...

HDU 2000-2099 解题报告.CHM

  • 2013-08-08 20:51
  • 831KB
  • 下载

HDU2501解题报告

  • 2014-07-10 10:44
  • 12KB
  • 下载

POJ 1905 Expanding Rods

Expanding Rods Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 12796  ...

HDU1019(2028)解题报告

  • 2014-07-11 10:05
  • 555B
  • 下载

2014NOIP普及组解题报告

  • 2015-01-30 10:06
  • 38KB
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)