poj 1905Expanding Rods
1 /* 2 二分 + 几何 3 弧长L, 圆半径R, 弧度 q, L=R*q; 4 二分: 弧度(0~PI) 或者 高度(L/2~L) 5 */ 6 #include<cstdio> 7 #include<iostream> 8 #include<cmath> 9 using namespace std; 10 const double PI = acos(-1.0); 11 double L, L1, T, C, R, Q; 12 13 int main(){ 14 15 while(scanf("%lf%lf%lf", &L, &T, &C) && (L!=-1 || T!=-1 || C!=-1)){ 16 L1 = (1+T*C)*L; 17 double ld=0.0, rd=PI, tmp; 18 Q = (ld+rd)/2; 19 R = L/2/sin(Q); 20 while(fabs(tmp = R*2*Q-L1)>1e-8){ 21 if(tmp>0) rd=Q; 22 else ld=Q; 23 Q=(ld+rd)/2; 24 R = L/2/sin(Q); 25 } 26 printf("%.3lf\n", R-sqrt(R*R - (L/2)*(L/2))); 27 } 28 return 0; 29 }
本文来自博客园,作者:hjzqyx,转载请注明原文链接:https://www.cnblogs.com/hujunzheng/p/3876698.html