eolymp
bolt
Try our new interface for solving problems
Problems

Spider and Fly - 2

Spider and Fly - 2

\includegraphics{https://static.e-olymp.com/content/4d/4dea9b29293256e07fdc80e51c480442e8b729b0.gif} In the empty rectangular room with the length \textbf{А}, the width \textbf{В} and the height \textbf{С} the fly fall onto the floor and fall a sleep. A spider which is lying on one of the walls or on the floor, or on the ceiling, starts moving to the fly by the shortest path. What distance will it cover? \InputFile The first line contains the sizes of the room \textbf{А}, \textbf{В}, \textbf{С}. The second line contains the coordinates of the fly on the floor \textbf{X1}, \textbf{Y1}, (\textbf{0} ≤ \textbf{X1} ≤ \textbf{A}, \textbf{0} ≤ \textbf{Y1} ≤ \textbf{B}). The third line contains the coordinates of the spider \textbf{X2}, \textbf{Y2}, \textbf{Z2}, (\textbf{0} ≤ \textbf{X2} ≤ \textbf{A}, \textbf{0} ≤ \textbf{Y2} ≤ \textbf{B}, \textbf{0} ≤ \textbf{Z2} ≤ \textbf{C}). All input values are integer nonnegative numbers less then or equal to \textbf{500}. \OutputFile The only number -- the distance which will be covered by the spider with two digits after the decimal point.
Time limit 1 second
Memory limit 64 MiB
Input example #37
4 7 3
2 1
3 7 2
Output example #37
8.06