ŔÂŇ
Language: Russian
English

Remote Training on Programming

Problems Online status Contests
News FAQ E-learning
For authors:
Register  ||  Login
 
Hello, Guest! Please login or register.

886. Spiral

Time Limit: 1 seconds
Memory Limit:65536KB
Points:100
View Problem Statistics Submit Problem added debug

An array is usually stored in RAM as a sequence of its elements. Traditionally, the element sequence is listed by rows or columns of the original array. However, in this task we will iterate the elements of a two-dimensional array (a rectangular matrix of size n*m) in a “spiral” fashion (see figure) starting at cell (1,1).

Write a program that will return the indices (row and column) of the element for given position in the spiral sequence.

Limitations

1 <= n, m <= 100; 1<= k <= n*m; 1 <= i <= n; 1 <= j <= m.

Input

The first line of the input file contains three integers n, m (matrix dimensions) and k (element position in a spiral sequence).

Output

The output file must contain two integers i and j – the indices of the array element corresponding to element number k in the spiral sequence.

Sample

Standard input

Standard output

3 3 3

1 3

4 5 6

2 5

 

 


View Problem Statistics Submit Problem discussion Author/source:
Problems from Contests and Camps / World Championship in Programming (ICPC) / Rybinsk-2010 /
886. 887. B - Beads game 888. C - Numbers 889. D - Bubble
Problems from Contests and Camps / Trainings of Vologda SU / Training 21.10.2010 /
886. 896. B - Megaspiral 245. C - Divisors 209. D - Calculator
time generating 0.125 sec.
© Copyright VSU, AVT, Nosov D.A., Andrianov I.A.