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

[luogu2148 SDOI2009] E&D (博弈论)

时间:2018-10-14 00:23:37      阅读:159      评论:0      收藏:0      [点我收藏+]

标签:lib   www   org   set   ++   getc   git   put   math   

传送门

Solution

我们知道当SG不为0则先手必胜,然后就可以打表了 ̄▽ ̄

Code

//By Menteur_Hxy
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define Re register
#define Ms(a,b) memset(a,(b),sizeof(a))
#define Fo(i,a,b) for(Re int i=(a),_=(b);i<=_;i++)
#define Ro(i,a,b) for(Re int i=(b),_=(a);i>=_;i--)
using namespace std;

inline int read() {
    int x=0,f=1;char c=getchar();
    while(!isdigit(c)) {if(c=='-')f=-f;c=getchar();}
    while(isdigit(c)) x=(x<<1)+(x<<3)+c-48,c=getchar();
    return x*f;
}

int main() {
    int T=read();
    while(T--) {
        int ans=0,n=read()/2;
        while(n--) {
            int cnt=0,x=((read()-1)|(read()-1));
            while(x&1) ++cnt,x>>=1;
            ans^=cnt;
        }
        puts(ans?"YES":"NO");
    }
    return 0;
}

[luogu2148 SDOI2009] E&D (博弈论)

标签:lib   www   org   set   ++   getc   git   put   math   

原文地址:https://www.cnblogs.com/Menteur-Hxy/p/9784669.html

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