2463: [Zhongshan election 2009] who can win? Time Limit:10 Sec Memory limit:128 MB
submit:1258 solved:917
[Submit] [Status] [Discuss]
DescriptionXiao Ming and Xiao Hong often play a game. Given a nxn chessboard, a stone is placed in the upper-left corner of the chessboard. They took turns to move the stone. Each turn, the player can only move the stone up, down, left and right in four directions, and asked to move to the grid can not be accessed before. No one can move a stone if he loses. If Xiaoming moves the stone first, and the two contestants move with the best strategy, ask the last who will win.
InputThe input file has multiple sets of data. Enter the first row contains an integer n that represents the size of the chessboard. When input n is 0 o'clock, the input end is indicated.
Output
For each set of data, if Xiaoming finally wins, the output is "Alice", otherwise the output "Bob", each group of answers is exclusive one line. Sample Input 2
0
Sample Output Alice HINT for all the data, guaranteed 1<=n<=10000.
Source
Simple game, the end of the game will be fully surrounded by the structure, the deduction will come out:
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
int n;
int main ()
{while
(scanf ("%d", &n), N)
{
if (n&1)
printf ("bob\n");
else
printf ("alice\n");
}