bzoj2463 [Zhongshan election 2009] who can win? __bzoj

Source: Internet
Author: User
Tags first row
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");
	}
    


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.