UVA 1482 SG打表
阿新 • • 發佈:2019-04-02
pre long \n clu ont for sin include using
打出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; }
UVA 1482 SG打表