zoukankan      html  css  js  c++  java
  • 湖南工业大学创新实验室2015年新生赛(一)1006(重开)

    Too simple

    Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)
    Total Submission(s) : 33   Accepted Submission(s) : 17

    Font: Times New Roman | Verdana | Georgia

    Font Size: ← →

    Problem Description

    Alice和Bob又在玩游戏惹。有一堆石子,石子总数为n。她们轮流取石子,每个人每次可以取走两个或者一个石子。另外如果Alice先手,那么取走最后一颗石子的输。如果Bob先手,那么取走最后一颗石子的获胜。假设两人都采取最佳策略,你的任务是根据石子数目和谁先手判断谁会赢。

    难度:★
    (hint:简单找规律即可。如果当前状态能够推出一个先手必败状态,那么当前状态为先手必胜状态。如果当前状态不能推出任一个先手必败状态,那么当前状态为先手必败状态)

    Input

    输入一个正整数t,接下来t组数据,每组包含n(1<=n<2^31)和Alice或Bob,代表先手的是谁

    Output

    对每组数据输出一行,输出胜者

    Sample Input

    3
    1 Alice
    2 Alice
    3 Bob

    Sample Output

    Bob
    Alice
    Alice

    Author

    bitchbitch

    Source

    light oj
     
    很简单的博弈,当需要取走最后一颗石子的获胜时,只要n%(m+1)!=0,则先取者一定获胜,当取走最后一颗石子的输时,有(n-1)%(m+1)==0则后手胜利
    #include<stdio.h>
    //#include<bits/stdc++.h>
    #include<string.h>
    #include<iostream>
    #include<math.h>
    #include<sstream>
    #include<set>
    #include<queue>
    #include<vector>
    #include<algorithm>
    #include<limits.h>
    #define inf 0x3fffffff
    #define lson l,m,rt<<1
    #define rson m+1,r,rt<<1|1
    #define LL long long
    using namespace std;
    int main()
    {
        int n,m,Case;
        string s;
        cin>>Case;
        while(Case--)
        {
            cin>>n>>s;
            if(s=="Bob")
            {
                if(n%(3)!=0)
                {
                    puts("Bob");
                }
                else
                {
                    puts("Alice");
                }
            }
            else
            {
                if((n-1)%3==0)
                {
                    puts("Bob");
                }
                else
                {
                    puts("Alice");
                }
            }
        }
    }
    

      

  • 相关阅读:
    C lang:Pointer operation
    C lang:Pointer and Array
    C lang:Array_Multidimensional arrays
    C lang: Pointer
    C lang:The smallest negative plus one equals the largest positive
    English:Day-to-day 1104
    IS:Introduction Parrot
    IS guide:Eric Steven Raymond in《How To Become A Hacker》
    Computer: Use the mouse to open the analog keyboard
    Markdown: color list
  • 原文地址:https://www.cnblogs.com/yinghualuowu/p/4995991.html
Copyright © 2011-2022 走看看