一眼看過去就是SG
但是再看一眼數據範圍,WC,打表的話數組開不到哇
想啊想,想啊想,晚上刷題好痛苦呀,想不出來呀,一看題解,打表找規律,WC,這也可以,可是我懶啊,不懶的話也可以打表找一下
打表找規律的話直接找板子稍微改一下就可以了,稍微改還不會,那就再好好看看SG吧
總之規律是
偶數 SG(n) = n >> 1
奇數 SG(n) = SG(n>>1)
然後當你知道了規律之後,你就開心的Ac了
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
#define LL long long
LL SG(LL n){
return (n&1)==0 ? (n>>1) : SG(n>>1);
}
int main(){
int T;
scanf("%d", &T);
while(T--){
int N;
scanf("%d", &N);
LL Xor = 0;
LL n;
for(int i = 0; i < N; i++){
scanf("%lld", &n);
Xor ^= SG(n);
}
if(Xor) printf("YES\n");
else printf("NO\n");
}
return 0;
}