2463: [Zhongshan City 2009] who can win? Time Limit: 10 sec memory limit: 128 MB
Submit: 729 solved: 512
[Submit] [Status] Description Xiao Ming and Xiao Hong often play a game. Given an n × n board, a stone is placed in the upper left corner of the Board. They move stones in turn. In each round, a contestant can only move the stone up, down, left, and right to a grid, and cannot be accessed before moving it to the grid. No one can move the stone. If James first moved the stone and both contestants took the best step, he asked who could win the game? The input file contains multiple groups of data. The first line contains an integer N, indicating the size of the Board. If n is 0, the input is complete.
Output
For each group of data, if James wins, "Alice" is output; otherwise, "Bob" is output, and each group of answers occupies one row.
Sample input2
0
Sample outputalicehint
For all data, ensure 1 <= n <= 10000.
Source
Question:
Randdorf 87:
Question
When N is an even number, it can be completely covered by 2*1 dominoes, so each time it goes to the other end of the dominoes, and another person can only go to the new dominoes until there is no
When N is an odd number, the first lattice can be completely covered by a 2*1 card, so the victory or defeat is reversed.
......
Why is it related to this ??? How can we think of it ???
Code:
1 var n:longint; 2 begin 3 assign(input,‘input.txt‘);assign(output,‘output.txt‘); 4 reset(input);rewrite(output); 5 read(n); 6 while n<>0 do 7 begin 8 if n and 1=1 then writeln(‘Bob‘) 9 else writeln(‘Alice‘);10 read(n);11 end;12 close(input);close(output);13 end.
View code