P2358 Ant Moving
Description
Consider a cube with edge length $1$. An ant starts from a point on the top face and crawls to a point on the bottom face. The ant can only move along the surface of the cube. Write a program to compute a shortest distance from the start to the end along the surface.
The coordinates of the start and end points are read from the keyboard. The coordinate origins on both the top and bottom faces are at the centers of their squares, and the $X$-axis and $Y$-axis directions of the two face coordinate systems are aligned. Output the answer rounded to three decimal places.
Input Format
$4$ real numbers (each in $[-0.5, 0.5]$), representing the coordinates of the starting point and the destination point.
Output Format
The shortest distance.
Explanation/Hint
Translated by ChatGPT 5