资源说明:Time limitation: 1 seconds Memory limitation: 64M
The game of nim is played as follows. Some number of sticks are placed in a pile.
Two players alternate in removing either one or two from the pile. The player who remove the last stick is the loser. The opponent remove sticks at the first, then it's your turn. Write a program to determine how many sticks should be removed when there's n sticks left in the pile.
Input
The first line is a integer n, which present how many data below. There's n integers m1, m2, ...mn on the following n lines, each line contains one of them, these number present how many sticks are there in the pile.
Output
For each mi, output how many sticks should be remove in this turn. If you will always lose no matter how many sticks are removed, output 0.
Input Sample
3
4
5
6
Output Sample
0
1
2
Source
BIT AsiaInfo CUP Programming Contest 2007
本源码包内暂不包含可直接显示的源代码文件,请下载源码包。