Line on Paper
Time limit1sMemory limit1024 MB
Given a step count N up to 10^18, the task is to find the grid cell reached by a spiral-like polyline path starting at (1, 1).
- Level
Easy3 of 10
- Topics
- Math, Simulation
- Solved
- No attempts yet
Problem
We trace the polyline shown in the figure below, moving one grid cell per step.

If we start at step on the cell with coordinates (1;1), which cell are we on at step ?
Input
The only line of the text file contains an integer ().
Output
Print one line with two integers separated by a space: the X and Y coordinates of the final cell.