V_AYP1_A - Kart
Pepe is a famous karting racer, but he forgot to tell his brother, Yonkleiderson, the number of his car so that could register in the competition, if Yonkleiderson fails to register his brother in the competition, his brother will be automatically disqualified. In a desperate moment, Yonkleiderson remembered that the number of the racer's car is given according to the starting position in the race, and he knows the position (i,j) where his brother's car is, the problem, then, is pretty simple, given N and M, that would be the size in a matrix and two values i,j that are the position at the matrix, Pepe wish to know what value could be in that position if the matrix is filled row by row starting from 1 until N*M.
Example
N= 3, M=4
1 2 3 4
5 6 7 8
9 10 11 12
i=0 , j=3 the number is 4
i=2 , j=2 the number is 11
i=1, j=0 the number is 5
Input details:
Four integers N,M,I,J representing the size of the matrix and the indexes i,j to search the car
Output details:
The number of the car as previously described in the statement.
INPUT |
OUTPUT |
3 4 0 3 |
4 |
Constraints
0 < N,M < 10000
0 <= i < N
0 <= j < M
Added by: | Venezuelan Programming League |
Date: | 2013-02-02 |
Time limit: | 5s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |