Logo
(追記) (追記ここまで)

9714번 - Spiral 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB36242466.667%

문제

Consider all positive integers written in the following manner (you can imagine an infinite spiral).

21 22 23 24 25 26
20 7 8 9 10 ...
19 6 1 2 11 ...
18 5 4 3 12 ...
17 16 15 14 13 ...

Your task is to determine the position (row,column) of a given number N, assuming that the center (number 1) has position (0,0). Rows are numbered from top to bottom, columns are numbered from left to right (for example, number 3 is at (1,1). Your program should output a string containing the position of N in the form (R,C) where R is the row and C is the column. R and C must not contain any leading zeroes.

입력

The first line of the input gives an integer T, which is the number of test cases. Each test case contains an integer N (1 ≤ N<231).

출력

For each test case, output the position as described above. See sample output for further clarification.

제한

예제 입력 1

7
2
3
7
17
24
830
765409

예제 출력 1

(0,1)
(1,1)
(-1,-1)
(2,-2)
(-2,1)
(-14,3)
(-437,221)

힌트

출처

ICPC > Regionals > Asia Pacific > Malaysia > Malaysia National Programming Contest > Al-Khawarizmi National Programming Contest 2011 B번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /