http://poj.org/problem?id=1905

#include<iostream>
#include<string>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
const double K=1e-10;
const double PI=acos(-1);
int main()
{
    double L,n,C;
    while(cin>>L>>n>>C)
    {
        if(L<0&&n<0&&C<0)
        break;
        double L1=(1+n*C)*L;
        double high=PI;
        double low=0;
        double mid=(high+low)/2;
        while(high-low>K)
        {
            //cout<<(mid/2)<<" "<<sin(mid/2)<<endl;
            //cout<<L1<<" "<<(mid*(L/2*asin(mid/2)))<<endl;
            if(L1-(mid*(L/2/sin(mid/2)))>=K)
            {
                low=mid;
            }
            else
            {
                high=mid;
            }
            mid=(high+low)/2;
        }
        //cout<<mid<<endl;
       printf("%.3f\n",(L/2/sin(mid/2)-L/2/tan(mid/2)));
    }
    return 0;
}

posted on 2012-05-08 20:01  夜->  阅读(150)  评论(0编辑  收藏  举报