BZOJ 1228 [SDOI2009]E&D
题解:
打表找规律
总游戏的SG=子游戏的SG的Nim和
计算子游戏的SG(x)=mex(SG(next[x]))
用找规律加速计算
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn=100009;
int TT;
int ans;
int n;
int SG(int x,int y){
	if((x%2)&&(y%2))return 0;
	return SG((x+1)/2,(y+1)/2)+1;
}
int main(){
	scanf("%d",&TT);
	while(TT--){
		scanf("%d",&n);
		ans=0;
		while(n){
			n-=2;
			int x,y;
			scanf("%d%d",&x,&y);
			ans^=SG(x,y);
		}
		if(ans)printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}
    致歉:笔者已经意识到这是一篇几乎没有价值的文章,给您的阅读带来不好的体验,并且干扰了您的搜索环境,非常抱歉!
                    
                
                
            
        
浙公网安备 33010602011771号