QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#611913 | #8022. Walker | LJY_ljy | WA | 0ms | 3920kb | C++11 | 1.1kb | 2024-10-05 00:11:04 | 2024-10-05 00:11:05 |
Judging History
answer
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const double eps = 1e-7;
const double INF = 1e10;
double n, p1, v1, p2, v2;
int main() {
int t; scanf("%d", &t);
for (int u = 1; u <= t; u++) {
scanf("%lf %lf %lf %lf %lf", &n, &p1, &v1, &p2, &v2);
if (p1 > p2) {
swap(p1, p2);
swap(v1, v2);
}
double l = 0, r = INF;
while (r - l > eps) {
double mid = (r + l) / 2;
double S1 = mid * v1, S2 = mid * v2;
bool flag = false;
// LL
if (S1 >= n + p1 || S2 >= n + p2) flag = true;
// RR
if (S1 >= 2 * n - p1 || S2 >= 2 * n - p2) flag = true;
// LR
if (S1 >= n + p1) flag = true;
if (S1 >= p1 + p2 && S1 < n + p1 && S2 >= n - p2) flag = true;
if (S1 < p1 + p2 && S1 + S2 >= 2 * n + p1 - p2) flag = true;
// RL
if (S1 >= n - p1 && S2 >= p2) flag = true;
if (S1 < n - p1 && S2 >= p2 + n) flag = true;
if (S2 < p2 && S1 >= 2 * n - p1) flag = true;
if (flag) r = mid;
else l = mid;
}
printf("%.10lf\n", l);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3868kb
input:
2 10000.0 1.0 0.001 9999.0 0.001 4306.063 4079.874 0.607 1033.423 0.847
output:
5000999.9999999627 3827.8370013273
result:
ok 2 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 3860kb
input:
1 10.0 1.0 10.0 9.0 0.1
output:
1.0999999522
result:
ok found '1.1000000', expected '1.1000000', error '0.0000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3868kb
input:
1 10.0 8.0 10.0 9.0 0.1
output:
1.1999999605
result:
ok found '1.2000000', expected '1.2000000', error '0.0000000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
1 10.0 8.0 0.1 9.0 10
output:
1.0999999522
result:
ok found '1.1000000', expected '1.1000000', error '0.0000000'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3920kb
input:
1 10.0 2.0 0.1 3.0 10
output:
1.2999999688
result:
ok found '1.3000000', expected '1.3000000', error '0.0000000'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3880kb
input:
1 10.0 9.0 0.1 8.0 10.0
output:
1.1999999605
result:
ok found '1.2000000', expected '1.2000000', error '0.0000000'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3864kb
input:
1 10.0 4.0 0.1 6.0 0.1
output:
59.9999999684
result:
ok found '60.0000000', expected '60.0000000', error '0.0000000'
Test #8:
score: -100
Wrong Answer
time: 0ms
memory: 3880kb
input:
1 10.0 4.5 0.1 6.0 0.1
output:
59.9999999684
result:
wrong answer 1st numbers differ - expected: '57.5000000', found: '60.0000000', error = '0.0434783'