#13 Spider and Fly

prb13

Picture Klimchuk Dasha Grade 9 20/10/2010

   In an empty rectangular room in the sizes ÀõÂõÑ (the length, width, height) has fallen to the floor the fallen asleep fly. The spider who was on one of walls, or on a room’s floor, has started to move to it on the shortest way.

   On what distance it thus will move?

Specifications

   Input

   In the first line it is set the sizes of a room À, Â, Ñ. In the second line - co-ordinates of a fly on the floor X1, Y1, and spider X2, Y2, Z2.

   All input date - the integers which are not exceeding 500.

   Output

   One line – the distance on which the spider will move, calculated to within 2 signs after a decimal point.

Time Limit: 1 seconds
Balls for the passed test: 10
Complexity: 56%

Example

Example input

1 1 1
1 1 1 1 0

Example output

0.00


Problem URL: http://www.e-olimp.com.ua/en/problems/13