这道嘛,很容易就看出是个nim和,然后问题就是怎么算子问题的sg函数了
先暴力个表看下规律,很容易就找出来了~~~(百度空间又渣了,图贴不出来= =)
32
0 1 0 2 0 1 0 3 0 1 0 2 0 1 0 4 0 1 0 2 0 1 0 3 0 1 0 2 0 1 0 5
1 1 2 2 1 1 3 3 1 1 2 2 1 1 4 4 1 1 2 2 1 1 3 3 1 1 2 2 1 1 5 5
0 2 0 2 0 3 0 3 0 2 0 2 0 4 0 4 0 2 0 2 0 3 0 3 0 2 0 2 0 5 0 5
2 2 2 2 3 3 3 3 2 2 2 2 4 4 4 4 2 2 2 2 3 3 3 3 2 2 2 2 5 5 5 5
0 1 0 3 0 1 0 3 0 1 0 4 0 1 0 4 0 1 0 3 0 1 0 3 0 1 0 5 0 1 0 5
1 1 3 3 1 1 3 3 1 1 4 4 1 1 4 4 1 1 3 3 1 1 3 3 1 1 5 5 1 1 5 5
0 3 0 3 0 3 0 3 0 4 0 4 0 4 0 4 0 3 0 3 0 3 0 3 0 5 0 5 0 5 0 5
3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 3 3 3 3 3 3 3 3 5 5 5 5 5 5 5 5
0 1 0 2 0 1 0 4 0 1 0 2 0 1 0 4 0 1 0 2 0 1 0 5 0 1 0 2 0 1 0 5
1 1 2 2 1 1 4 4 1 1 2 2 1 1 4 4 1 1 2 2 1 1 5 5 1 1 2 2 1 1 5 5
0 2 0 2 0 4 0 4 0 2 0 2 0 4 0 4 0 2 0 2 0 5 0 5 0 2 0 2 0 5 0 5
2 2 2 2 4 4 4 4 2 2 2 2 4 4 4 4 2 2 2 2 5 5 5 5 2 2 2 2 5 5 5 5
0 1 0 4 0 1 0 4 0 1 0 4 0 1 0 4 0 1 0 5 0 1 0 5 0 1 0 5 0 1 0 5
1 1 4 4 1 1 4 4 1 1 4 4 1 1 4 4 1 1 5 5 1 1 5 5 1 1 5 5 1 1 5 5
0 4 0 4 0 4 0 4 0 4 0 4 0 4 0 4 0 5 0 5 0 5 0 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5 0 5 0 5 0 5 0 5
5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
只能这样了= =
很容易就能写出来了= =
CODE:
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int solve(int x,int y) {
int n=31;
for (int m=30;m;m--) {
int t=1<<m;
if (x<=t&&y<=t) n=m;
if (x>t) x-=t;
if (y>t) y-=t;
}
return (x==1&&y==1)?0:n;
}
int main(){
int T;
scanf("%d",&T);
while (T--) {
int n,ans=0;
scanf("%d",&n);
for (int i=1;i<=n;i+=2){
int x,y;
scanf("%d%d",&x,&y);
ans^=solve(x,y);
}
printf("%s\n",ans?"YES":"NO");
}
return 0;
}