精度限定到1e-12即可。
http://poj.org/problem?id=1905
1 #include <cstdio> 2 #include <cmath> 3 4 using namespace std; 5 6 const double pi = 3.14159265359; 7 const double ep = 1e-12; 8 9 double l, n, c; 10 11 void solve(){ 12 double low = ep, high = pi / 2; 13 double l1 = (1 + n * c) * l; 14 double d1, d2, mid; 15 d2 = l / l1; 16 while(high - low > ep){ 17 mid = (low + high) / 2; 18 d1 = sin(mid) / mid; 19 if(d1 > d2) low = mid; 20 else high = mid; 21 } 22 d1 = sin(low), d2 = sin(low / 2); 23 printf("%.3f ", l * d2 * d2 / d1); 24 } 25 26 int main(){ 27 //freopen("in.txt", "r", stdin); 28 while(~scanf("%lf%lf%lf", &l, &n, &c) && (l + 1)){ 29 solve(); 30 } 31 return 0; 32 }