zoukankan      html  css  js  c++  java
  • 取石子(sg函数)

    Alice和Bob有n桶石子,里面有ai个,他们每次只能其中一某堆里取奇数个,不能拿的人输,Alice总是先拿
    1<=n<=200,1<=ai<=1e9
    Input
    第一行为 n
    第二行为 n个数 ai
    Output
    最后获胜的人Alice或Bob
    Sample Input
    3
    3 2 1
    Sample Output
    Bob

    #include <iostream>
    #include<algorithm>
    #include <stdio.h>
    #include <string>
    #include <string.h>
    #include <map>
    #include <math.h>
    #include <vector>
    #include <set>
    #include <queue>
    #include <map>
    #include <deque>
    //#include <bits/stdc++.h>
    using namespace std;
    typedef  long long ll;
    const int N=4e5+7;
    const int mod=1e9+7;
    inline ll read(){
        ll s=0,w=1;
        char ch=getchar();
        while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
        while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
        return s*w;
    }
    int main()
    {
        int x,n;
        while(cin>>n)
        {
            int ans=0;
            int m=n;
            while(n--)
            {
                cin>>x;
                if(x&1)
                    ans++;
            }
    
            if(ans%2==0)
                cout<<"Bob"<<endl;
            else
                cout<<"Alice"<<endl;
        }
        return 0;
    }
    

      

  • 相关阅读:
    BeanUtils.copyProperties的用法
    WinRAR下载
    安装Perl
    @Value设置默认值
    AutoHotkey
    解决springboot启动日志异常问题
    除以2换成位移操作(骚)
    IDEA生成doc文档生成chm文档
    VMWare虚拟机网络配置
    EOF小结
  • 原文地址:https://www.cnblogs.com/zzl_Alexander/p/11930087.html
Copyright © 2011-2022 走看看