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;
    }
    

      

  • 相关阅读:
    点分治 / 点分树题目集
    HNOI2019 游记
    WC2019 题目集
    SA / SAM 题目集
    Min_25 筛小结
    NOIP2018 差点退役记
    Atcoder 乱做
    DP及其优化
    计数与概率期望小结
    分库分表之后全局id咋生成?
  • 原文地址:https://www.cnblogs.com/zzl_Alexander/p/11930087.html
Copyright © 2011-2022 走看看