ŔÂŇ
Language:

Remote Training on Programming

Problems On-line status Contests FAQ
For authors:
Register  ||  Login
 
Hello, Guest! Login or register.

886. Spiral

Time Limit: 1 seconds
Memory Limit:32768KB
Points:10
View Problem Statistics Submit Problem added Administrator

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 Author/source:
Problems from Contests / ACM Contests / Rybinsk-2010 /
886. 887. B - Beads game 888. C - Numbers 889. D - Bubble
Problems from Contests / Trainings of Vologda STU / Training 21.10.2010 /
886. 896. B - Megaspiral 245. C - Divisors 209. D - Calculator
We can all benefit by doing occasional "toy" programs, when artificial restrictions are set up, so that we are forced to push our abilities to the limit. The art of tackling miniproblems with all our energy will sharpen our talents for the real problems. Donald E. Knuth.
time generating 0.124 sec.
© Copyright VSTU, AVT, Nosov D.A.