QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#166601#7110. Kuririn MIRACLEucup-team045ML 2ms4412kbC++201.7kb2023-09-06 15:27:202023-09-06 15:27:20

Judging History

你现在查看的是最新测评结果

  • [2023-09-06 15:27:20]
  • 评测
  • 测评结果:ML
  • 用时:2ms
  • 内存:4412kb
  • [2023-09-06 15:27:20]
  • 提交

answer

#include<iostream>
#include<cstring>
#include<vector>
#include<cmath>
#include<iomanip>
using namespace std;
using LL = long long;
const double PI = acos(-1);
double v, R, d;

double f(double x){
    double sinx = sin(x);
    return 1 / v / (sqrt(sinx * sinx + 3) - sinx);
}

const double eps = 1e-12;

double simpson(double l, double r){
    double mid = (l + r) / 2;
    return (r - l) * (f(l) + 4 * f(mid) + f(r)) / 6;
}

double asr(double l, double r, double s){
    auto mid = (l + r) / 2;
    auto left = simpson(l, mid), right = simpson(mid, r);
    if (fabs(left + right - s) < eps) return left + right;
    return asr(l, mid, left) + asr(mid, r, right);
}

int main(){

#ifdef LOCAL
    freopen("data.in", "r", stdin);
    freopen("data.out", "w", stdout);
#endif

    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    int T;
    cin >> T;
    while(T--){
        cin >> v >> R >> d;

        auto check = [&](double mid){
            double l = d - v * mid;
            if (l + eps < 4 * R) return false;
            double a = PI - acos(2 * R / (l - 2 * R));
            double ans = asr(0, a, simpson(0, a)) * 2 * R;
            double dist = sqrt((l - 2 * R) * (l - 2 * R) - 4 * R * R);
            ans += dist * f(a);
            return ans <= mid;
        };

        double l = 0, r = (d - 4 * R) / v;
        for(int i = 0; i < 100; i++){
            double mid = (l + r) / 2;
            if (check(mid)) r = mid;
            else l = mid;
        }
        
        double ans = d / v;
        if (l <= r + eps && check(r)) ans = min(ans, r);
        cout << ans << '\n';
    }

}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 4412kb

input:

1
2.00 3 30.0

output:

8.31057993391192262322

result:

ok found '8.3105799', expected '8.3105799', error '0.0000000'

Test #2:

score: -100
Memory Limit Exceeded

input:

100
8.66 6.05 71.59
8.44 8.67 82.55
4.23 9.68 24.74
6.63 9.95 7.45
1.2 7.27 97.55
2.08 2.94 31.61
8.48 5.56 20.16
7.35 5.55 52.48
1.35 8.15 51.23
3.88 9.02 72.37
7.03 1.97 57.03
1.78 4.44 93.44
5.5 6.11 52.94
1.09 9.64 69.01
1.01 3.54 16.78
1.63 4.55 44.06
5.82 5.51 5.92
5.62 2.93 76.01
4.75 4.43 73...

output:


result: