tjut 5954

#include <bits/stdc++.h>
using namespace std;
double Pi = acos(-1.0);
double eps = 1e-100;
double tran = 180/Pi;
double vd;
double V(double a) {
    return Pi*cos(a) - a*cos(a) + sin(a) - pow(sin(a), 3)/3;
}
double get(double theta) {
    double a1 = acos(2*tan(theta)-1);
    double v = (V(a1) - V(Pi))/tan(theta);
    return v;
}
bool eq(double x, double y) {
    return fabs(x-y) < eps;
}
double find(double l, double r) {
    int cnt = 200;
    if(eq(get(l), vd)) return l;
    while(cnt--) {
        double mid = (l+r) / 2;
        double gd = get(mid);
        if(eq(gd, vd)) return mid;
        if(gd > vd) r = mid;
        else l = mid;
    }
    return l;
}
int main() {
    int T;
    scanf("%d", &T);
    while(T--) {
        double d;
        scanf("%lf", &d);
        vd = d * Pi;
        if(eq(d, 0)) {
            printf("0.00000\n");
            continue;
        }
        if(d - 1 > 0) {
            double theta = atan(2.0-d);
            double ans = Pi/cos(theta);
        //  printf("d>1 theta = %.5f\n", theta*tran);
            printf("%.5f\n", ans);
            continue;
        }
        double theta = find(eps, Pi/4);
        double a1 = acos(2 * tan(theta) - 1);
        double S1 = Pi - a1 + cos(a1) * sin(a1);
        double ans = S1 / sin(theta);
        printf("%.5f\n", ans);
    }
    return 0;
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章