题目:http://poj.org/problem?id=1905
恶心死了,POJ的输出一会要lf,一会要f,而且精度1e-13才过,1e-12都不行,错了一万遍终于对了。
1 #include <stdio.h> 2 #include <math.h> 3 4 int main() 5 { 6 double l, n, c, r; 7 while(scanf("%lf %lf %lf", &l, &n, &c) != EOF) 8 { 9 if(l < 0 && n < 0 && c < 0)break; 10 double arc = (1 + n*c) * l; 11 double low = 0, high = acos(-1.0) / 2; 12 while(high-low > 1e-13) 13 { 14 double mid = (high+low) / 2; 15 r = l/2 / sin(mid); 16 if(r * mid < arc / 2) 17 { 18 low = mid; 19 } 20 else 21 { 22 high = mid; 23 } 24 } 25 printf("%.3lf ", r-r*cos(low)); 26 } 27 return 0; 28 }