All submissions for this problem are available.
Aliens have attacked the Earth! Now, the General secretary of the UN has asked you to find out the position of the main spaceship of the aliens. On the coordinate system, the spaceship starts at (0,0).Then the spaceship makes N Turns. On the first turn the spaceship goes 1 unit right On the second turn, the spaceship goes 2 units up. On the third turn, the spaceship goes 3 units to the left. On the fourth turn, the spaceship goes 4 units down. On the fifth turn, the spaceship goes 5 units to the right. And so on. The G.sec of the UN will give you the number of turns the spaceship has turned and you in turn, have to find out its position after performing the turns.
For each test case output a single line, containing two integers - the coordinates of the spaceship.
- 1 ≤ T ≤ 10000
- 1 ≤ N ≤ 10^9
Input: 4 1 2 3 4 Output: 1 0 1 2 -2 2 -2 -2
|Time Limit:||0.09 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.5, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.