UVA 1482 SG打表
打出SG表来可以很容易的发现i为偶数时 SG[i]=i/2 i为奇数时 SG[i]=SG[i/2]
#include<bits/stdc++.h> typedef long long ll; using namespace std; ll SG(ll x) { return x&1?SG(x/2):x/2; } int main() { int t; scanf("%d", &t); while (t--) { int n; ll a, v = 0; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%lld", &a); v ^= SG(a); } if (v) printf("YES\n"); else printf("NO\n"); } return 0; }