HDU 2509 Be the Winner(取火柴博弈2)

传送门

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;

int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        int a,res=0;
        int c=0,g=0;
        for(int i=0;i<n;i++)
        {
            scanf("%d",&a);
            if(a>=2) c++;
            else if(a==1) g++;
            res^=a;
        }
        if(!res)
        {
            if(c>=2)//T2
                printf("No
");
            else if(c==0)
                printf("Yes
");
        }
        else//S
        {
            if(g&1&&c==0)//S0
                printf("No
");
            else if(c==1||c>=2)//S1,S2
                printf("Yes
");
        }
    }
    return 0;
}
原文地址:https://www.cnblogs.com/atmacmer/p/5233291.html