QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#673973 | #8022. Walker | ty | WA | 108ms | 58680kb | Java11 | 1.5kb | 2024-10-25 12:40:41 | 2024-10-25 12:40:41 |
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.0000001;
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 + (mid-eps-x)*2;
double ly = (n-y) + (y - (mid-eps))*2;
double rx = x + (mid+eps-x)*2;
double ry = (n-y) + (y - (mid+eps))*2;
if(cal(lx,vx,ly,vy) < cal(rx,vx,ry,vy)) r = mid;
else l = mid;
}
double mid = (l+r)/2;
double lx = x + (mid-x)*2;
double ly = (n-y) + (y - (mid))*2;
//System.out.printf("%.5f\n",cal(lx,vx,ly,vy));
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: 108ms
memory: 55188kb
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: 108ms
memory: 55504kb
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: 94ms
memory: 53836kb
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: 97ms
memory: 58104kb
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: 98ms
memory: 57748kb
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: 108ms
memory: 58168kb
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: 99ms
memory: 54488kb
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: 0
Accepted
time: 106ms
memory: 57928kb
input:
1 10.0 4.5 0.1 6.0 0.1
output:
57.50000
result:
ok found '57.5000000', expected '57.5000000', error '0.0000000'
Test #9:
score: 0
Accepted
time: 97ms
memory: 54656kb
input:
1 10.0 1.0 1.0 8.0 1.0
output:
6.50000
result:
ok found '6.5000000', expected '6.5000000', error '0.0000000'
Test #10:
score: -100
Wrong Answer
time: 98ms
memory: 58680kb
input:
1 10.0 3.0 2.0 7.0 1.0
output:
4.66667
result:
wrong answer 1st numbers differ - expected: '4.6000000', found: '4.6666700', error = '0.0144935'