Bzoj2463: [Zhongshan City selects 2009] who can win?

Source: Internet
Author: User
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

 

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.