• UVA-12293(组合游戏)


    题意:

    有两个相同的盒子,一个盒子里面有n个球,另一个盒子里面有1个球,每次清空球较少的那个盒子,然后从另外的一个盒子里拿到空盒子里使得操作后两个盒子至少有一个球,判断是先手还是后者胜;

    思路:

    跟每次拿走至少一个且不超过一半那个一样的sg函数;

    AC代码:

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    #include <cmath>
    //#include <bits/stdc++.h>
    #include <stack>
    
    using namespace std;
    
    #define For(i,j,n) for(int i=j;i<=n;i++)
    #define mst(ss,b) memset(ss,b,sizeof(ss));
    
    typedef  long long LL;
    
    template<class T> void read(T&num) {
        char CH; bool F=false;
        for(CH=getchar();CH<'0'||CH>'9';F= CH=='-',CH=getchar());
        for(num=0;CH>='0'&&CH<='9';num=num*10+CH-'0',CH=getchar());
        F && (num=-num);
    }
    int stk[70], tp;
    template<class T> inline void print(T p) {
        if(!p) { puts("0"); return; }
        while(p) stk[++ tp] = p%10, p/=10;
        while(tp) putchar(stk[tp--] + '0');
        putchar('
    ');
    }
    
    const LL mod=1e9+7;
    const double PI=acos(-1.0);
    const int inf=1e9;
    const int N=2e6+10;
    const int maxn=500+10;
    const double eps=1e-8;
    
    int get_sg(int x)
    {
        if(x%2==0)return x/2;
        return get_sg(x/2);
    }
    int main()
    {       
            int n;
            while(1)
            {
                read(n);
                if(n==0)break;
                if(get_sg(n))printf("Alice
    ");
                else printf("Bob
    ");
            }    
            
            return 0;
    }
    
     
    

      

  • 相关阅读:
    商品表(spu)、规格表(sku)设计
    Links
    About
    AFO
    口胡题
    NOIP2014 飞扬的小鸟
    CSP2019 Emiya 家今天的饭
    CSP2019 括号树
    CSP-J2019 加工零件
    CSP-J2019 纪念品
  • 原文地址:https://www.cnblogs.com/zhangchengc919/p/5701554.html
Copyright © 2020-2023  润新知