but, it’s the same thing, the expression given in the editorial is just more simplified than what I’ve written, it should give AC in both the cases. Still can’t figure out where I went wrong…
please read the ans below when you divide first you lose precision as there are only say 19 digits after the decimal. Moreover expression d/1000/tx50x3600 yields wrong ans but dx3600x50/t/1000 yields right answer. You should check the links in my answer. I tried almost 40 diff. solutions to check this out.
So lets look this sample with your code
1
7 213 221 7 6
int this case the other car sped is 217, your solution calculates with floats
the other car speed is in your code oc = 216.99998
diff1 : 3.9999847
diff2 : 4.0000153
if I change the floats to double in your code : oc will be = 216.99999999999997
diff1: 3.9999999999999716
diff2 : 4.0000000000000284
so you can see it also contains precision error.
Of course you can correct your solution if ABS(diff1 - diff2) < epsilon it should be consider equal. For your solution e.g. epsilon=1e-7 would be a sufficient.