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;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值