文件名称:nim(简单)_组合数学
文件大小:235B
文件格式:TXT
更新时间:2017-04-12 12:45:59
北京理工大学 组合数学 编程题
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