Sdut 3004-Box game (game)

Source: Internet
Author: User

Topic Link: Click to open the link

Test instructions: 2 people game problem.

There are two identical boxes, One of them has n balls and the other one is loaded with a ball. Alice and Bob invented a game with the following rules:

Alice and Bob take turns, and Alice operates first. For each operation, the player first looks at the number of balls in the box, then empties the box (the ball in the box is thrown away), and then takes the ball from the other box to the box so that two boxes have at least one ball. If a player is unable to operate, he or she loses.

One place to compare pits is when two stacks of items are the same, you can take any pile instead of just losing it. Visible (a) is the final state. Push to find that when N is 2^m-1 Bob wins, anyway Alice will win.

#include <algorithm> #include <iostream> #include <cstring> #include <cstdlib> #include < string> #include <cctype> #include <vector> #include <cstdio> #include <cmath> #include < queue> #include <stack> #include <map> #include <set> #define MAXN 10100#define _ll __int64#define ll Long long#define INF 0x3f3f3f3f#define Mod 1000000007#define pp pair<int,int> #define ull unsigned long longusing nam Espace std;int n;int Main () {while (scanf ("%d", &n)!=eof&&n) {++n;while (!) ( n&1)) n>>=1;if (n==1) puts ("Bob"), Else puts ("Alice");    return 0;}

Sdut 3004-Box game (game)

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.