Take stone (SG function)

Alice and Bob have n barrel stone, which has a ai, they can only take one of a pile of odd number, the person can not get lost, Alice always acquire
1 <= n <= 200,1 < = ai <= 1E9
the Input
first row n
second row number n AI
the Output
final winner who Alice or Bob
the Sample the Input
. 3
. 3 2. 1
the Sample the 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;
}

  

Guess you like

Origin www.cnblogs.com/zzl-dreamfly/p/11930087.html
sg