eolymp
bolt
Try our new interface for solving problems

Spiral

Consider all positive integers written in the following manner (you can imagine an infinite spiral). \includegraphics{https://static.e-olymp.com/content/2b/2b33143abf4f9d4f136557841e5b833af02b0e5a.jpg} Your task is to determine the position (row,column) of a given number \textbf{N}, assuming that the center (number \textbf{1}) has position (\textbf{0},\textbf{0}). Rows are numbered from top to bottom, columns are numbered from left to right (for example, number \textbf{3} is at (\textbf{1},\textbf{1}). Your program should output a string containing the position of \textbf{N} in the form (\textbf{R},\textbf{C}) where \textbf{R} is the row and \textbf{C} is the column. \textbf{R} and \textbf{C} must not contain any leading zeroes. \InputFile The first line of the input gives an integer \textbf{T}, which is the number of test cases. Each test case contains an integer \textbf{N }(\textbf{1} ≤ \textbf{N} < \textbf{2^31}). \OutputFile For each test case, output the position as described above. See sample output for further clarification.
Zaman məhdudiyyəti 1 saniyə
Yaddaşı istafadə məhdudiyyəti 64 MiB
Giriş verilənləri #1
7
2
3
7
17
24
830
765409
Çıxış verilənləri #1
(0,1)
(1,1)
(-1,-1)
(2,-2)
(-2,1)
(-14,3)
(-437,221)
Mənbə ACM-ICPC Malaysia al-Khawārizmī Programming Contest 2011