LightOJ1020 (game)

Source: Internet
Author: User

Alice and Bob is playing a game with marbles; You are played this game in childhood. The game is playing by alternating turns. In each turn a player can take exactly one or both marbles.

Both Alice and Bob know the number of marbles initially. Now the game can is started by any one. But the winning condition depends on the player starts it. If Alice starts first, then the player takes the last marble looses the game. If Bob starts first, then the player takes the last marble wins the game.

Now is given the initial number of marbles and the name of the player who starts first. Then you have to find the winner of the game if both of them play optimally.
Input

Input starts with an integer T (≤10000), denoting the number of test cases.

Each case contains a integer n (1≤n < 231) and the name of the player who starts first.
Output

For each case, print the case number and the name of the winning player.
Sample Input

Output for Sample Input

3

1 Alice

2 Alice

3 Bob

Case 1:bob

Case 2:alice

Case 3:alice

Find a circular section directly

    /************************************************************************* > File Name:LightOJ1020.cpp > Author:alex > Mail:zchao1995@gmail.com > Created time:2015 June 09 Tuesday 18:46 32 sec * * /#include <functional> #include < algorithm> #include <iostream> #include <fstream> #include <cstring> #include <cst
    dio> #include <cmath> #include <cstdlib> #include <queue> #include <stack>  #include <map> #include <bitset> #include <set> #include <vector> using namespace

    Std
    Const double PI = ACOs (-1.0);
    const int inf = 0X3F3F3F3F;
    Const double EPS = 1e-15;
    typedef long Long LL;

    typedef pair &LT;INT, int> PLL;
        int main () {int T, icase = 1;
        scanf ("%d", &t);
     while (t--) {       int n;
            string S;
            CIN >> N >> S;
            n%= 3;
            cout << "Case" << icase++ << ":";
                if (s[0] = = ' A ') {if (n = = 1) {printf ("bob\n");
                } else {printf ("alice\n");
                }} else {if (n = = 0) {printf ("alice\n");
                } else {printf ("bob\n");
    }}} return 0;
 }

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.