Submit  All submissions  Best solutions  Back to list 
SPIRAL  Spiral 
Wersja polska  English version 
Input
There is unknown number of tests. Each of them consists of one line in which appear two integers: n (0<n<=10^{6}; n always odd)  size of the square matrix and m (0<m<=n^{2})  the number of the choosen cell.
Output
For each test print index of the row and index of the column of the choosen cell which is determined by m.
Example
Input:
7 28
5 13
1 1
5 1
5 5
3 9
Output:
7 4
5 1
1 1
3 3
2 2
3 3
Added by:  Piotr Kąkol 
Date:  20100510 
Time limit:  1.659s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: NODEJS OBJC SCM qobi VB.NET 
Resource:  Author of the problem: David Déharbe; Author of the illustration: Wanderley Guimarães 
hide comments


20100517 07:40:18 Zoltán Zámbori
Piotr, can you copy the largest numbers (n,m,row,column) from the tests? 

20100515 18:00:39 Piotr KÄ…kol
Perl shouldn't be so slow if Your program in C has 0.14. It might be caused by: 0  
20100514 22:40:23 Zoltán Zámbori
I rewrote my C code into Perl (#3627710). C needs 0.09 sec to finish, but the Perl code run >10 sec (TLE). It is my fault, or Perl is really so slow? Last edit: 20100514 22:51:48 