Numerical spiral
Medium
Execution time limit is 1 second
Runtime memory usage limit is 64 megabytes
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.
Input
It is given three integers, separated by spaces: N (1 ≤ N ≤ 10^9) - 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.
Examples
Input #1
Answer #1
Submissions 951
Acceptance rate 21%