QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#673959 | #8022. Walker | ty | WA | 112ms | 59016kb | Java11 | 1.4kb | 2024-10-25 12:27:30 | 2024-10-25 12:27:32 |
Judging History
answer
import java.util.Scanner;
public class Main {
public static double cal(double lx,double vx,double ly,double vy) {
return Math.max(lx/vx,ly/vy);
}
public static void main(String[] arg) {
Scanner input = new Scanner(System.in);
int caset = input.nextInt();
double eps = 0.00000001;
while(caset > 0) {
caset--;
double n = input.nextDouble();
double x = input.nextDouble();
double vx = input.nextDouble();
double y = input.nextDouble();
double vy = input.nextDouble();
if(x > y) {
double c = x;
double vc = vx;
x = y;
vx = vy;
y = c;
vy = vc;
}
double t1 = Math.max((n-x)/vx,y/vy);
double t2 = (x + n-y + n)/(vx + vy);
double t3 = Math.min((Math.min(x,n-x) + n)/vx,(Math.min(y,n-y) + n)/vy);
double l = x;
double r = y;
while(r - l > eps) {
double mid = (l+r)/2;
double lx = x*2 + (mid-eps-x);
double ly = (n-y)*2 + y - (mid-eps);
double rx = x*2 + (mid+eps-x);
double ry = (n-y)*2 + y - (mid+eps);
if(cal(lx,vx,ly,vy) < cal(rx,vx,ry,vy)) r = mid;
else l = mid;
}
double mid = (l+r)/2;
double lx = x*2 + (mid-x);
double ly = (n-y)*2 + y - (mid);
double ans = Math.min(t1,t2);
ans = Math.min(ans,t3);
ans = Math.min(ans,cal(lx,vx,ly,vy));
System.out.printf("%.5f\n",ans);
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 98ms
memory: 59016kb
input:
2 10000.0 1.0 0.001 9999.0 0.001 4306.063 4079.874 0.607 1033.423 0.847
output:
5001000.00000 3827.83700
result:
ok 2 numbers
Test #2:
score: 0
Accepted
time: 97ms
memory: 55428kb
input:
1 10.0 1.0 10.0 9.0 0.1
output:
1.10000
result:
ok found '1.1000000', expected '1.1000000', error '0.0000000'
Test #3:
score: 0
Accepted
time: 92ms
memory: 55684kb
input:
1 10.0 8.0 10.0 9.0 0.1
output:
1.20000
result:
ok found '1.2000000', expected '1.2000000', error '0.0000000'
Test #4:
score: 0
Accepted
time: 100ms
memory: 54396kb
input:
1 10.0 8.0 0.1 9.0 10
output:
1.10000
result:
ok found '1.1000000', expected '1.1000000', error '0.0000000'
Test #5:
score: 0
Accepted
time: 99ms
memory: 54332kb
input:
1 10.0 2.0 0.1 3.0 10
output:
1.30000
result:
ok found '1.3000000', expected '1.3000000', error '0.0000000'
Test #6:
score: 0
Accepted
time: 93ms
memory: 48692kb
input:
1 10.0 9.0 0.1 8.0 10.0
output:
1.20000
result:
ok found '1.2000000', expected '1.2000000', error '0.0000000'
Test #7:
score: 0
Accepted
time: 90ms
memory: 55668kb
input:
1 10.0 4.0 0.1 6.0 0.1
output:
60.00000
result:
ok found '60.0000000', expected '60.0000000', error '0.0000000'
Test #8:
score: -100
Wrong Answer
time: 112ms
memory: 48988kb
input:
1 10.0 4.5 0.1 6.0 0.1
output:
60.00000
result:
wrong answer 1st numbers differ - expected: '57.5000000', found: '60.0000000', error = '0.0434783'