Numerical spiral
Except of addition to finding the sum of digits, Tiger also likes to represent numbers in the form of a square matrix with size NxN. In the matrix are recorded serial numbers starting with 1. The filling of the matrix is going clockwise from both directions. The first direction begins from the upper-left corner of the matrix, and the second - from bottom right corner.
During the filling of the matrix numbers, Tigre was curious to know what the number is at the intersection of I-th row and J-th column.
Specifications
Input
It is given three integers, separated by spaces: N (1 ≤ N ≤ 109) - the dimension of the matrix and I, J (1 ≤ I, J ≤ N) - the line number and column.
Output
One number, which is located at the intersection of I-th row and J-th column.
Problem information
Time Limit: 1 secondsMemory Limit: 64 MB
Balls for the passed test: 5
Complexity: 78% 5/23
Autor: Ruban Nikolaj
Example
Example input6 4 4 |
Example output17 |
| ← A Lucky number of Tiger`s | Problems | Trams → |
