Expanding Rods
1 #include<cstdio> 2 #include<cstring> 3 #include<cmath> 4 #include<algorithm> 5 using namespace std; 6 7 const double eps=1e-8; 8 double n,c,l; 9 10 int main() 11 { 12 while(scanf("%lf%lf%lf",&l,&n,&c)&&l!=-1&&n!=-1&&c!=-1){ 13 double s=(1+n*c)*l; 14 double low=0,high=0.5*l,mid; 15 while(high-low>eps) 16 { 17 mid=(high+low)/2; 18 double r=(4*mid*mid+l*l)/(8*mid); 19 double ss=2*r*asin(l/(2*r)); 20 if(ss<s) 21 low=mid; 22 else 23 high=mid; 24 } 25 printf("%.3lf\n",mid); 26 } 27 return 0; 28 }