A higher resolution is required to access the IDE
- 330
Learning Opportunities
This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.
Statement
Goal
Ataria lives on a toroidal map known as the Mystic Rectangle, where opposite edges of the map are connected. Crossing an edge teleports her to the opposite side. Ataria can move in any of the four cardinal directions or along the four diagonals of 45 degrees.Given Ataria's coordinates and the coordinates of the goal, find the fastest time for her to reach the goal, assuming no obstacles.
Moving East or West ±1 unit in x takes
Moving North or South ±1 unit in y takes
It takes
After travelling for 1 minute in any single cardinal direction (that is,
Example
Suppose Ataria starts near the top of the map and travels diagonally
Input
Line 1: Two space separated integers x and y for the current position
Line 2: Two space separated integers u and v for the location of the goal
Line 2: Two space separated integers u and v for the location of the goal
Output
Line 1: The decimal time to the goal in seconds, with precision of tenths
Constraints
0 ≤ x, u < 200
0 ≤ y, v < 150
0 ≤ y, v < 150
Example
Input
50 15 65 145
Output
9.5
A higher resolution is required to access the IDE