码迷,mamicode.com
首页 > 其他好文 > 详细

XDOJ_1184_博弈

时间:2016-11-02 20:03:30      阅读:209      评论:0      收藏:0      [点我收藏+]

标签:while   log   turn   https   else   can   std   bsp   stream   

http://acm.xidian.edu.cn/problem.php?id=1184

 

Sprague-Grundy定理

https://zhuanlan.zhihu.com/p/20611132#!

a[i]%3=0时,为必败态。

a[i]%3=1时,为一级胜态。

a[i]%3=2时,为二级胜态。

 

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

int n;

int main()
{
    while(~scanf("%d",&n))
    {
        int ans = 0,t;
        for(int i = 1;i <= n;i++)
        {
            scanf("%d",&t);
            ans ^= t%3;
        }
        if(ans) printf("Yes\n");
        else    printf("No\n");
    }
    return 0;
}

 

XDOJ_1184_博弈

标签:while   log   turn   https   else   can   std   bsp   stream   

原文地址:http://www.cnblogs.com/zhurb/p/6024041.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!