10182-bee Maja
Time limit:3.000 seconds
Http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem &problem=1123
Maja is a bee. She lives in a bee hive with thousands of the other bees. This bee hive consists of many hexagonal honey combs where the honey are stored in. But Bee Maja has a problem. Willi told her where she can meet him, but because, Willi are a male drone and Maja is a female worker they have different C Oordinate systems.
Maja ' s coordinate System |
Willi ' s coordinate System |
maja who often flies directly to a special honey the comb has the laid a advanced two dimensional grid over the whole hive. |
willi who are more lazy and often walks around just the numbered cells St Arting from 1 in the middle of the hive. |
|
Help Maja to convert Willi ' s system to hers. Write a program which for a given honey comb number gives the coordinates in Maja ' s system.
Input specification
The input file contains one or more integers which represent Willi ' s numbers. Each number is stands on it own in a separate line, and directly followed by a newline. The honey comb numbers are all less than 100 000.
Output specification
You are should output the corresponding Maja coordinates to Willi ' s numbers, each coordinate pair on a separate line.
Sample Input
1
2
3
4
5
Sample Output
0 0
0 1
-1 1
-1 0
0-1
O (1) Complexity of the train of thought: This problem if only look at the map on the left, you will find that each vertical column ordinate the same, and the lower left oblique each column ordinate the same. But this does not identify the relationship between these points, in fact, to change the angle, if the left coordinate in a rectangular coordinate system, it is easier to see that this is a very regular diagram, only need to cross ordinate the addition and subtraction is good, as for the addition and reduction of how much that depends on the number of layers, The number of layers can be calculated according to the general terms of the coordinates on the x-axis.