QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#611893 | #8022. Walker | LJY_ljy | WA | 1ms | 3872kb | C++11 | 969b | 2024-10-04 23:48:43 | 2024-10-04 23:48:43 |
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 + S2 >= 2 * n + p1 - p2) flag = true;
// RL
if (S1 >= n - p1 && S2 >= p2) flag = true;
if (S1 < n - p1 && S1 + S2 >= 2 * n) flag = true;
if (S2 < p2 && S1 + S2 >= 2 * n) 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: 3872kb
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: -100
Wrong Answer
time: 0ms
memory: 3860kb
input:
1 10.0 1.0 10.0 9.0 0.1
output:
1.1881187700
result:
wrong answer 1st numbers differ - expected: '1.1000000', found: '1.1881188', error = '0.0801080'