zoukankan      html  css  js  c++  java
  • Educational Codeforces Round 68 (Rated for Div. 2)-D. 1-2-K Game

    output
    standard output

    Alice and Bob play a game. There is a paper strip which is divided into n + 1 cells numbered from left to right starting from 0. There is a chip placed in the n-th cell (the last one).

    Players take turns, Alice is first. Each player during his or her turn has to move the chip 1, 2 or k cells to the left (so, if the chip is currently in the cell i, the player can move it into cell i - 1, i - 2 or i - k). The chip should not leave the borders of the paper strip: it is impossible, for example, to move it k cells to the left if the current cell has number i < k. The player who can't make a move loses the game.

    Who wins if both participants play optimally?

    Alice and Bob would like to play several games, so you should determine the winner in each game.

    Input

    The first line contains the single integer T (1 ≤ T ≤ 100) — the number of games. Next T lines contain one game per line. All games are independent.

    Each of the next T lines contains two integers n and k (0 ≤ n ≤ 109, 3 ≤ k ≤ 109) — the length of the strip and the constant denoting the third move, respectively.

    Output

    For each game, print Alice if Alice wins this game and Bob otherwise.

    Example
    input
    Copy
    4
    0 3
    3 3
    3 4
    4 4
    output
    Copy
    Bob
    Alice
    Bob
    Alice

     代码:

    #include<cstdio>
    #include<iostream>
    #include<cstring>
    #include<algorithm>
    #include<queue>
    #include<stack>
    #include<set>
    #include<vector>
    #include<map>
    #include<cmath>
    const int maxn=1e5+5;
    typedef long long ll;
    using namespace std;
     
    int main()
    {
        int T;
        scanf("%d", &T);
        while (T--)
        {
            int n, k;
            scanf("%d%d", &n, &k);
            if (k == 3)
            {
                if(n%4!=0)
                {
                    puts("Alice
    ");
                }
                else
                {
                    puts("Bob");
                }
     
            }
            else if (k % 3 == 0)
            {
                n %= (k + 1);
                if (n % 3 == 0 && n != k)
                    puts("Bob");
                else
                    puts("Alice");
            }
            else
            {
                if(n%3!=0)
                {
                    puts("Alice
    ");
                }
                else
                {
                    puts("Bob");
                }       
            }
        }
    }
  • 相关阅读:
    作为前端开发兼任产品专员是一种咋样的体验
    css忽略某一层的存在:pointer-events:none
    响应式网站对百度友好关键
    移动站点对百度友好全解
    如何布局您的PC站和移动站,并表达两者之间内容的对应关系
    猫眼电影App抓包获取评论数据接口
    字符串模拟大数相加——Java实现
    计算机网络知识小结
    二叉树与双向链表问题
    算法编程题积累(4)——腾讯笔试"有趣的数字“问题
  • 原文地址:https://www.cnblogs.com/Staceyacm/p/11190395.html
Copyright © 2011-2022 走看看