Can someone explain the second test case. thx
z-teleport
You are at point A(0; 0; 0)
Zearth is at point B(2; 2; 2)
You gain the best result, if you travel through the given point C(1; 1; 1)
So you actually make two distances: A -> C and C -> B.
It can be seen that they are of equal length.
Now we just calculate the distance A -> C. Using a formula that determines the length of a diagonal of cuboid (d = sqrt(a^2 + b^2 + c^2), where a, b and c are the lengths of the edges), we get that AC = sqrt(3) and that is approximately 1.73. And that is your answer.
Zearth is at point B(2; 2; 2)
You gain the best result, if you travel through the given point C(1; 1; 1)
So you actually make two distances: A -> C and C -> B.
It can be seen that they are of equal length.
Now we just calculate the distance A -> C. Using a formula that determines the length of a diagonal of cuboid (d = sqrt(a^2 + b^2 + c^2), where a, b and c are the lengths of the edges), we get that AC = sqrt(3) and that is approximately 1.73. And that is your answer.
And we don't calculate C - > B ?
If you calculate C -> B it turns out to be the same - sqrt(3).
I am just explaining the example. The actual solution is for you to come up with.
I am just explaining the example. The actual solution is for you to come up with.
... He need to go trough the safest path.
So I think it should be like this,
- first he go from (0,0,0) to (1,1,1) cause this is the safest path.( dist=1.73)
-then he won't go directly to the end point cause this isn't the safest path, so he choose one of the two other points. (2,2,1) or (1,2,2) it doesn't matter wich cause the distance is the same.(dist=1.41)
- and at least he go from that point to the end point(2,2,2). ( dist = 1 )
So at the end the maximal distance he made on the safest path is 1.73 + 1.41 + 1 = 4.14.
So that's what i think, and I guess its wrong. So can somebody tell how it should be?
So I think it should be like this,
- first he go from (0,0,0) to (1,1,1) cause this is the safest path.( dist=1.73)
-then he won't go directly to the end point cause this isn't the safest path, so he choose one of the two other points. (2,2,1) or (1,2,2) it doesn't matter wich cause the distance is the same.(dist=1.41)
- and at least he go from that point to the end point(2,2,2). ( dist = 1 )
So at the end the maximal distance he made on the safest path is 1.73 + 1.41 + 1 = 4.14.
So that's what i think, and I guess its wrong. So can somebody tell how it should be?
Safest path means that the longest distance between any 2 points on that path should be minimal. So that is 1.73 in this case, and you should output that