poj 1905 Expanding Rods(二分)
生活随笔
收集整理的這篇文章主要介紹了
poj 1905 Expanding Rods(二分)
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
題目:http://poj.org/problem?id=1905
題意:看圖就明白了。。。
桿原長(zhǎng)為L(zhǎng),受熱膨脹彎曲后的長(zhǎng)度為?L'=(1+n*C)*L,求中心的移動(dòng)的距離h;
思路:推出兩個(gè)公式:s為弧長(zhǎng)
對(duì)h進(jìn)行二分,得出r,代入(2)式,與s進(jìn)行大小比較
代碼:
View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cmath> 4 using namespace std; 5 const double esp=1e-5; //最低精度限制 6 int main() 7 { 8 double L,n,C; 9 while(scanf("%lf%lf%lf",&L,&n,&C)!=EOF) 10 { 11 if(L<0&&n<0&&C<0) 12 break; 13 double LL; 14 LL=(1+n*C)*L; 15 double low,high; 16 double R,mid; 17 low=0; 18 high=L/2; 19 while(high-low>esp) 20 { 21 mid=(high+low)/2; 22 R=((mid*mid*4)+(L*L))/(8*mid); 23 if((2*R*asin(L/(2*R)))<LL) 24 low=mid; 25 else 26 high=mid; 27 } 28 printf("%.3f\n",mid); 29 } 30 return 0; 31 }?
轉(zhuǎn)載于:https://www.cnblogs.com/wanglin2011/archive/2013/02/21/2920433.html
總結(jié)
以上是生活随笔為你收集整理的poj 1905 Expanding Rods(二分)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 通过shell例子来学习循环结构的语法
- 下一篇: Path菜单