2530.Hexagons

Time Limit: 1s Memory Limit: 256MB

Ayrat is looking for the perfect code. He decided to start his search from an infinite field tiled by hexagons. For convenience the coordinate system is introduced, take a look at the picture to see how the coordinates of hexagon are defined: 2530_1.png2530_2.png Ayrat is searching through the field. He started at point (0,0) and is moving along the spiral (see second picture). Sometimes he forgets where he is now. Help Ayrat determine his location after n moves.

Input Format(From the terminal/stdin)

Input The only line of the input contains integer n (0 \le n \le 1018)- the number of Ayrat's moves.

Output Format(To the terminal/stdout)

Output Print two integers x and y- current coordinates of Ayrat coordinates.

Sample Input 1

Copy
3
 \n

Sample Output 1

Copy
-2 0
  · \n

Sample Input 2

Copy
7
 \n

Sample Output 2

Copy
3 2
 · \n

Submit

请先 登录

© 2025 FAQs