QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#743393#8022. WalkerForacyWA 1ms3856kbC++20959b2024-11-13 19:06:462024-11-13 19:06:47

Judging History

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

  • [2024-11-13 19:06:47]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3856kb
  • [2024-11-13 19:06:46]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using LL = long long;
double n,a,va,b,vb;
bool check(double t){
    double a1 = (va*t - a);
    double a2 = (va*t - a) / 2 + a;
    double b1 = (vb*t - (n-b));
    double b2 = (vb*t - (n-b)) / 2 + (n-b);
    if (a1+b1 >= n || a1+b2 >= n || a2+b1 >= n || a2+b2 >= n){
        return 1;
    }
    return 0;
}
int main(){
    cout << fixed << setprecision(10);
    int T;
    cin >> T;
    while (T--){
        cin >> n >> a >> va >> b >> vb;
        if (a > b){
            swap(a,b);
            swap(va,vb);
        }
        double case1 = min({(n+a)/va,(n+b)/vb,max((n-a)/va,(n-b)/vb)});
        double lo = 0, hi = case1;
        while (lo <= hi){
            double mid = (lo + hi) / 2;
            if (check(mid)){
                hi = mid - 0.00000001;
            } else{
                lo = mid + 0.00000001;
            }
        }
        cout << lo << '\n';
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3856kb

input:

2
10000.0 1.0 0.001 9999.0 0.001
4306.063 4079.874 0.607 1033.423 0.847

output:

5000999.9999999935
3827.8370013744

result:

ok 2 numbers

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3848kb

input:

1
10.0 1.0 10.0 9.0 0.1

output:

1.0447761174

result:

wrong answer 1st numbers differ - expected: '1.1000000', found: '1.0447761', error = '0.0502035'