QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#707713 | #8022. Walker | xiey | TL | 0ms | 3976kb | C++20 | 1.3kb | 2024-11-03 17:11:10 | 2024-11-03 17:11:11 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
double n, p1, v1, p2, v2;
inline bool check(double t)
{
double a = p1;
double b = p2 - p1;
double c = n - p2;
double x1, x2;
if (t * v1 - 2 * a >= 0)
{
x1 = a + max(t * v1 - 2 * a, (t * v1 - a) / 2);
}
else
{
if (t * v1 - a >= 0)
{
x1 = a + (t * v1 - a) / 2;
}
else
{
x1 = 0;
}
}
if (t * v2 - 2 * c >= 0)
{
x2 = n - c - max(t * v2 - 2 * c, (t * v2 - c) / 2);
}
else
{
if (t * v2 - c >= 0)
{
x2 = n - c - ((t * v2 - c) / 2);
}
else
{
x2 = n;
}
}
if (x2 <= x1)
return 1;
else
return 0;
}
void solve()
{
scanf("%lf%lf%lf%lf%lf", &n, &p1, &v1, &p2, &v2);
if (p1 > p2)
{
swap(p1, p2);
swap(v1, v2);
}
double l = 0, r = 5e7;
while (r - l > 1e-9)
{
double mid = (l + r) / 2;
if (check(mid))
r = mid;
else
l = mid;
}
printf("%.9lf\n", l);
}
int main()
{
int t = 1;
scanf("%d", &t);
while (t--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3920kb
input:
2 10000.0 1.0 0.001 9999.0 0.001 4306.063 4079.874 0.607 1033.423 0.847
output:
5000999.999999999 3827.837001375
result:
ok 2 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 3848kb
input:
1 10.0 1.0 10.0 9.0 0.1
output:
1.099999999
result:
ok found '1.1000000', expected '1.1000000', error '0.0000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3976kb
input:
1 10.0 8.0 10.0 9.0 0.1
output:
1.199999999
result:
ok found '1.2000000', expected '1.2000000', error '0.0000000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3932kb
input:
1 10.0 8.0 0.1 9.0 10
output:
1.099999999
result:
ok found '1.1000000', expected '1.1000000', error '0.0000000'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3908kb
input:
1 10.0 2.0 0.1 3.0 10
output:
1.299999999
result:
ok found '1.3000000', expected '1.3000000', error '0.0000000'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3916kb
input:
1 10.0 9.0 0.1 8.0 10.0
output:
1.199999999
result:
ok found '1.2000000', expected '1.2000000', error '0.0000000'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3960kb
input:
1 10.0 4.0 0.1 6.0 0.1
output:
60.000000000
result:
ok found '60.0000000', expected '60.0000000', error '0.0000000'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3932kb
input:
1 10.0 4.5 0.1 6.0 0.1
output:
57.500000000
result:
ok found '57.5000000', expected '57.5000000', error '0.0000000'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
1 10.0 1.0 1.0 8.0 1.0
output:
6.499999999
result:
ok found '6.5000000', expected '6.5000000', error '0.0000000'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3912kb
input:
1 10.0 3.0 2.0 7.0 1.0
output:
4.600000000
result:
ok found '4.6000000', expected '4.6000000', error '0.0000000'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3928kb
input:
1 10.0 6.0 2.0 7.0 1.0
output:
3.666666666
result:
ok found '3.6666667', expected '3.6666667', error '0.0000000'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3912kb
input:
1 10.0 1.0 1.0 9.0 1.0
output:
6.000000000
result:
ok found '6.0000000', expected '6.0000000', error '0.0000000'
Test #13:
score: -100
Time Limit Exceeded
input:
1 10000.0 1.0 0.001 1.0 0.001