• Gym 100952 G. The jar of divisors


    G. The jar of divisors
    time limit per test
    2 seconds
    memory limit per test
    64 megabytes
    input
    standard input
    output
    standard output

    Alice and Bob play the following game. They choose a number N to play with. The rules are as follows:

    - They write each number from 1 to N on a paper and put all these papers in a jar.

    - Alice plays first, and the two players alternate.

    - In his/her turn, a player can select any available number M and remove its divisors including M.

    - The person who cannot make a move in his/her turn wins the game.

    Assuming both players play optimally, you are asked the following question: who wins the game?

    Input

    The first line contains the number of test cases T (1  ≤  T  ≤  20). Each of the next T lines contains an integer (1  ≤  N  ≤  1,000,000,000).

    Output

    Output T lines, one for each test case, containing Alice if Alice wins the game, or Bob otherwise.

    Examples
    Input
    2
    5
    1
    Output
    Alice
    Bob
    这道题我自己都有点迷茫,是个博弈题,结论就是n%6==1?"Bob":"Alice"
    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <queue>
    #include <cmath>
    #include <map>
    #include <vector>
    #include <algorithm>
    using namespace std;
    #define lowbit(x) (x&(-x))
    #define max(x,y) (x>y?x:y)
    #define min(x,y) (x<y?x:y)
    #define MAX 100000000000000000
    #define MOD 1000000007
    #define PI 3.141592653589793238462
    #define INF 0x3f3f3f3f3f
    #define mem(a) (memset(a,0,sizeof(a)))
    typedef long long ll;
    int main()
    {
        ll t,n;
        scanf("%lld",&t);
        while(t--)
        {
            cin>>n;
            if(n%6==1) puts("Bob");
            else puts("Alice");
        }
        return 0;
    }


  • 相关阅读:
    经济学原理---10 外部性-- 读书笔记
    经济学原理---9应用:国际贸易--- 读书笔记
    人月神话阅读笔记之一
    小水王
    构建之法读书笔记之五
    课堂作业
    时间记录日志
    构建之法读书笔记之四
    查找水王程序
    代码阅读方法与实践阅读笔记01
  • 原文地址:https://www.cnblogs.com/shinianhuanniyijuhaojiubujian/p/7199270.html
Copyright © 2020-2023  润新知