poj1936(公式+二分)

参考(http://blog.csdn.net/lyy289065406/article/details/6648562)

#include <iostream>
#include <bitset>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iomanip>
using namespace std;
double l,n,c;
double eps = 1e-6;
int main()
{
    while (cin>>l>>n>>c) {
        if (l<0&&n<0&&c<0) {
            break;
        }
        double s = (1+n*c)*l;
        double ma = l/2,mi = 0;
        double mid = (ma+mi)/2;
        while (ma-mi>eps) {
            mid = (ma+mi)/2;
            double r = (4*mid*mid+l*l)/8/mid;
            if (s-2*r*asin(l/2/r)>eps) {
                mi = mid;
            }
            else
                ma = mid;
        }
        cout<<fixed<<setprecision(3)<<mid<<endl;
    }
    return 0;
}
已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页