您的位置:首页 > 其它

FOJ--1083--Expanding Rods--解题报告

2009-08-04 18:57 190 查看
WhenathinrodoflengthLisheatedndegrees,itexpandstoanewlengthL'=(1+n*C)*L,whereCisthecoefficientofheatexpansion.

Whenathinrodismountedontwosolidwallsandthenheated,itexpandsandtakestheshapeofacircularsegment,theoriginalrodbeingthechordofthesegment.



Yourtaskistocomputethedistancebywhichthecenteroftherodisdisplaced.

Input

Theinputcontainsmultiplelines.Eachlineofinputcontainsthreenon-negativenumbers:theinitiallenthoftherodinmillimeters,thetemperaturechangeindegreesandthecoefficientofheatexpansionofthematerial.Inputdataguaranteethatnorodexpandsbymorethanonehalfofitsoriginallength.Thelastlineofinputcontainsthreenegativenumbersanditshouldnotbeprocessed.

Output

Foreachlineofinput,outputonelinewiththedisplacementofthecenteroftherodinmillimeterswith3digitsofprecision.

Sampleinput

10001000.0001
15000100.00006
1000.001
-1-1-1

Outputforsampleinput

61.329
225.020
0.000

分析:这题主要是先找出关系,在用二分法求解


代码如下:

#include<stdio.h>
#include<math.h>
intmain()
{
doublel,c,n,ll,t,min,max,mid,y,r,h;
while(scanf("%lf%lf%lf",&l,&n,&c)!=-1)
{
if(l==-1&&n==-1&&c==-1)
break;
if(n*c==0)
printf("%.3lf/n",0.0);
else
{
ll=(1+c*n)*l;
t=l/ll;
min=0;
max=acos(0);
for(inti=0;i<100;i++)
{
mid=(min+max)/2;
y=sin(mid)-t*mid;
if(y>0)
min=mid;
else
max=mid;
}
h=(1-cos(mid))*ll/2/mid;
printf("%.3lf/n",h);
}
}
}


[/code]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: