QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#161388#7110. Kuririn MIRACLEucup-team004#AC ✓205ms4432kbC++202.0kb2023-09-02 23:37:282023-09-02 23:37:29

Judging History

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

  • [2023-09-02 23:37:29]
  • 评测
  • 测评结果:AC
  • 用时:205ms
  • 内存:4432kb
  • [2023-09-02 23:37:28]
  • 提交

answer

#include <bits/stdc++.h>

using i64 = long long;

const double Pi = std::acos(-1.0);
constexpr double EPS = 1e-9;
double v, r, d;
double f(double x) {
    double s = std::sin(x);
    return 1 / v / (std::sqrt(s * s + 3) - s);
}
double simpson(double l, double r) {
    return (f(l) + 4 * f((l + r) / 2) + f(r)) * (r - l) / 6;
}
double integral(double l, double r, double eps, double st) {
    double mid = (l + r) / 2;
    double sl = simpson(l, mid);
    double sr = simpson(mid, r);
    if (std::abs(sl + sr - st) <= 15 * eps)
        return sl + sr + (sl + sr - st) / 15;
    return integral(l, mid, eps / 2, sl) + integral(mid, r, eps / 2, sr);
}
double integral(double l, double r) {
    return integral(l, r, EPS, simpson(l, r));
}
void solve() {
    std::cin >> v >> r >> d;
    r *= 2;
    
    auto check = [&](double t) {
        double x = d - v * t;
        assert(x - r >= r);
        double u = Pi - std::acos(r / (x - r));
        double ans = 0;
        double px = r - std::cos(u) * r;
        double py = std::sin(u) * r;
        double dis = std::sqrt((x - px) * (x - px) + py * py);
        ans += integral(0, u) * r;
        ans += dis * f(u);
        // std::cerr << t << " " << ans << " " << u << " " << integral(0, u) * r << " " << dis << " " << dis * f(u) << "\n";
        return ans <= t;
    };
    
    double ans = d / v;
    double lo = 0, hi = (d - 2 * r) / v - EPS;
    if (hi < lo) {
        std::cout << ans << "\n";
        return;
    }
    for (int _ = 0; _ < 100; _++) {
        double t = (lo + hi) / 2;
        if (check(t)) {
            hi = t;
        } else {
            lo = t;
        }
    }
    if (check(hi)) {
        ans = hi;
    }
    std::cout << ans << "\n";
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    std::cout << std::fixed << std::setprecision(10);
    
    int t;
    std::cin >> t;
    
    while (t--) {
        solve();
    }
    
    return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1
2.00 3 30.0

output:

8.3105799339

result:

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

Test #2:

score: 0
Accepted
time: 25ms
memory: 4432kb

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:

4.4578371227
5.4883608090
5.8486997636
1.1236802413
43.2664800535
8.3054901382
2.3773584906
4.0154859695
37.9481481481
18.6520618557
4.1551236436
27.1789630071
9.6254545455
63.3119266055
16.6138613861
15.0939944612
1.0171821306
6.9496235027
8.1504302992
8.8584474886
1.7697642164
4.5411392405
10.4731...

result:

ok 100 numbers

Test #3:

score: 0
Accepted
time: 205ms
memory: 4416kb

input:

1000
7.52 6.68 80.67
5.34 6.82 45.75
3.57 6.35 22.35
9.55 3.65 31.38
9.37 5.73 40.42
1.83 8.38 82.97
4.86 6.13 9.45
3.88 5.34 84.19
6.49 4.15 85.24
6.51 7.23 42.97
3.0 5.98 57.53
9.35 2.76 69.07
6.76 9.16 91.24
2.98 9.89 49.2
9.16 3.85 66.14
1.84 3.03 37.43
8.01 5.04 50.98
4.05 9.86 4.76
5.4 5.49 60...

output:

5.7708826493
8.5674157303
6.2605042017
3.2858638743
4.3137673426
25.1764841720
1.9444444444
11.4062996164
6.8071912056
6.6006144393
10.7277125608
3.8001978448
7.4844843026
16.5100671141
3.7756970122
10.9157110705
3.5175276460
1.1753086420
6.0952874389
14.4431818182
8.4168240742
8.4894553076
6.028112...

result:

ok 1000 numbers

Extra Test:

score: 0
Extra Test Passed