QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#624193#8022. WalkerTankYoung#WA 1ms3848kbC++14959b2024-10-09 15:12:212024-10-09 15:12:22

Judging History

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

  • [2024-10-09 15:12:22]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3848kb
  • [2024-10-09 15:12:21]
  • 提交

answer

#include <bits/stdc++.h>
const double S = 0.0000001;
using namespace std;

double walk(double pos, double l, double r, double v)
{
    double ret = (r - l) / v;
    ret += min((r - pos) / v, (pos - l) / v);
    return ret;
}
void solve()
{
    double n, p1, p2, v1, v2;
    cin >> n >> p1 >> v1 >> p2 >> v2;
    if (p1 > p2)
    {
        swap(p1, p2); swap(v1, v2);
    }
    double ans = min(walk(p1, 0.00000000, n, v1), walk(p2, 0.0000000, n, v2));
    double l = p1, r = p2, tmp1, tmp2;
    for (int i = 1; i <= 400; i++)
    {
        double mid = (l + r) / 2.0000000;
        tmp1 = walk(p1, 0, mid, v1); tmp2 = walk(p2, mid, n, v2);
        if (tmp1 >= tmp2) r = mid;
        else l = mid;
    }
    ans = min(ans, min(walk(p1, 0, r, v1), walk(p2, r, n, v2)));
    cout <<fixed<<setprecision(10)<< ans << '\n';
}
int main()
{
    int T;
    cin >> T;
    while (T--)
    {
        solve();
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
10000.0 1.0 0.001 9999.0 0.001
4306.063 4079.874 0.607 1033.423 0.847

output:

5001000.0000000000
3827.8370013755

result:

ok 2 numbers

Test #2:

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

input:

1
10.0 1.0 10.0 9.0 0.1

output:

1.0000000000

result:

wrong answer 1st numbers differ - expected: '1.1000000', found: '1.0000000', error = '0.0909091'