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
Outputforsampleinput
[/code]
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]
相关文章推荐
- FOJ--1635--Commandos--解题报告
- FOJ--1046--Tempter of the Bone--解题报告(典型的迷宫搜索)
- foj 2170 花生壳的序列 解题报告
- FOJ--1589--自动机--解题报告
- FOJ--1490--五子棋--解题报告
- FOJ1650-A^B mod C解题报告
- FOJ 2013 A short problem 解题报告
- FOJ 1083 Expanding Rods
- FOJ--1698--最大乘积--解题报告(大数乘小数的问题)
- BZOJ大视野 1083: [SCOI2005]繁忙的都市 解题报告
- I - Expanding Rods解题报告(黄杰)
- POJ-1905 Expanding Rods 解题报告(二分) 金属材料的膨胀
- LuoguP1083 借教室[NOIP2012] 解题报告【二分答案+差分】
- pku 1905 二分 Expanding Rods 解题报告
- FOJ--1685--跑跑卡丁车--解题报告
- POJ-1905 Expanding Rods 解题报告
- FOJ--1339--Calculator--解题报告
- FOJ--1096--QS Network--解题报告
- foj 1844 题解题报告 + 源代码
- poj1083 解题报告(poj 1083 analysis report)