QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#611910 | #8022. Walker | LJY_ljy | WA | 1ms | 3924kb | C++11 | 1.1kb | 2024-10-05 00:05:06 | 2024-10-05 00:05:08 |
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 >= 2 * n + p1 - p2 || S2 >= 2 * n) flag = true;
// RR
if (S1 >= 2 * n || S2 >= 2 * n + p1 - 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: 1ms
memory: 3924kb
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: 1ms
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: 1ms
memory: 3816kb
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: -100
Wrong Answer
time: 1ms
memory: 3872kb
input:
1 10.0 8.0 0.1 9.0 10
output:
1.8811880526
result:
wrong answer 1st numbers differ - expected: '1.1000000', found: '1.8811881', error = '0.7101710'