//ZOJ的类似题
//State: ZOJ2083    C++    0    188
//题目大意:A和B轮流给n条线染色(A先),每人每次只能染一条
//          线的一段(长度为2)。不能染色者为输。

#include <iostream>
#include <stdio.h>
#include <cstring>
using namespace std;

const int MAX = 55;
int sg[MAX];
int get_sg(int n)
{
    if(sg[n] != -1)
        return sg[n];
    if(!n || n == 1)
        return sg[n] = 0;
    bool vst[MAX] = {false};
    if(n >= 2)
    {
        int t = n - 2, t2 = t / 2;
        for(int i = 0; i <= t2; i++)
        {
            int s = get_sg(t - i) ^ get_sg(i);
            vst[s] = true;
        }
    }
    for(int i = 0; i < MAX; i++)
    {
        if(!vst[i])
            return sg[n] = i;
    }
}

int main(void)
{
    int n;
    memset(sg, -1, sizeof(sg));
    while(scanf("%d", &n) == 1)
    {
        int m, yihuo = 0;
        for(int i = 0; i < n; i++)
        {
            scanf("%d", &m);
            yihuo ^= get_sg(m);
        }
        if(!yihuo)
            printf("No\n");
        else
            printf("Yes\n");
    }
    return 0;
}
posted on 2012-08-04 16:50  cchun  阅读(206)  评论(0编辑  收藏  举报