The Parquet of the Triangles
We laid by three-cornered tiles the rectangular room with sides M to N (at first for hori-zontal lines, and then for vertical lines) and we numbered it as shown on the picture.
It is possible to move from one parquet to another through a general side only for one step. Find the least quantity of steps, which necessary for transferring from parquet A to parquet B.
Specifications
Input
In the input file in the first line through the gap is set to M, N (1 ≤ M, N ≤ 100), and the second - A, B.
Output
The desired number of steps.
Problem information
Time Limit: 1 secondsMemory Limit: 64 MB
Balls for the passed test: 6.66667
Complexity: 30% 85/122
Example
Example input5 4 25 38 |
Example output5 |
| ← The Segments | Problems | The Red and Blue Squares → |
