Time

17:59:25
22 May 2012
Version for print

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.

prb1055

   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 (1N109) - the dimension of the matrix and I, J (1I, JN) - 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 seconds
Memory Limit: 64 MB
Balls for the passed test: 5
Complexity: 78% 5/23
Autor: Ruban Nikolaj

Example

Example input

6 4 4

Example output

17


← A Lucky number of Tiger`s Problems Trams →