This page is still under construction.

Parts of this page are still being built. What you see may change.

Bee Maja

Time limit1sMemory limit128 MB

Summary
Convert a spiral hex-grid cell number into hexagonal axial coordinates using the orientation shown in the sample.
Level

Medium5 of 10

Topics
Math, Implementation, Simulation, Geometry
Solved
No attempts yet

Problem

Maja is a worker bee who lives in a hive together with thousands of other bees. The hive is a honeycomb: a grid of hexagonal cells in which honey is stored.

Maja wants to meet Willi, a male drone, but the two of them describe the hive with different coordinate systems.

Maja's coordinate systemWilli's coordinate system
Maja often flies straight to a particular cell, so she has laid a two-dimensional grid over the whole hive. Every cell has an (x,y)(x, y) position, and the central cell is (0,0)(0, 0).Willi walks rather than flies, so he simply numbered the cells in a spiral: cell 11 is the central cell, and the numbers grow outward one ring at a time.

Given a cell number in Willi's system, output that cell's coordinates in Maja's system. The exact orientation of the spiral is the one shown by the sample.

Input

The input contains one or more integers, each of them one of Willi's cell numbers. Each number is given on its own line. Every cell number is less than 100 000100\,000.

Output

For each of Willi's numbers, output the coordinates of that cell in Maja's system as two integers x y separated by a single space, one pair per line, in the same order as the input.

Examples1

  1. Example 1

    Input
    1
    2
    3
    4
    5
    
    Expected output
    0 0
    0 1
    -1 1
    -1 0
    0 -1