CODCHESS - Naya Shatranj (New Chess)
A and B are playing a very interesting variant of the ancient Indian game 'shatranj' (also known as chess) on a 'maidaan' (chessboard) n×n in size.
They take turns to put game pieces called 'ghoda'(knight) so that no two 'ghodas' (knights) could threaten each other.
A 'ghoda' located in square (a, b) can threaten squares (a + 1, b + 2), (a - 1, b + 2), (a + 1, b - 2), (a - 1, b - 2), (a + 2, b - 1), (a + 2, b + 1), (a - 2, b - 1), (a - 2, b + 1).
The player who can't put a new 'ghoda' during his move loses. Find out which player wins considering that both players play optimally well and A starts.
Input
The first line contains integer T (1≤T≤10^4) — the number of 'maidaans' (boards), for which you should determine the winning player. Next T lines contain T integers ni (1 ≤ ni ≤ 10^5) — the sizes of the 'maidaans' (chessboards).
Output
For each ni×ni board print on a single line "0" if A wins considering both players play optimally well. Otherwise, print "1".
Example
Input: 2 2 1 Output: 1 0
hide comments
Anshuman Mourya:
2015-08-05 10:37:07
very easy one... |
|
anuveshkothari:
2015-08-03 16:01:24
just check till 5-6 numbers and you will get the pattern |
|
anshal dwivedi:
2015-07-27 06:45:31
my 100th!!
|
|
K0d1:
2015-04-07 00:53:10
I personally feel that the ideology applied here is wrong.The chances of winning are equally likely in the cases of 3x3 & 4x4(lost interest to look after that). One can understand this just by enumerating with 3x3 board.Winning or losing depends on the position where B places his ghoda in his turn.
|
|
Hardik Dosi:
2015-03-23 08:20:33
Plenty of these type here on SPOJ (-_-) |
|
Rajat (1307086):
2015-03-19 23:58:38
Perhaps, the easiest! :) |
Added by: | CSI |
Date: | 2013-09-27 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |