题意:
有n堆石子,分别有a1,a2,...,an个,两个游戏者轮流操作,每次可以选一堆m拿走至少一个且不超过一半的石子,谁不能拿石子就算输;
思路:
a1太大打印sg表找规律,然后就是异或和了;
AC代码:
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> //#include <bits/stdc++.h> #include <stack> using namespace std; #define For(i,j,n) for(int i=j;i<=n;i++) #define mst(ss,b) memset(ss,b,sizeof(ss)); typedef long long LL; template<class T> void read(T&num) { char CH; bool F=false; for(CH=getchar();CH<'0'||CH>'9';F= CH=='-',CH=getchar()); for(num=0;CH>='0'&&CH<='9';num=num*10+CH-'0',CH=getchar()); F && (num=-num); } int stk[70], tp; template<class T> inline void print(T p) { if(!p) { puts("0"); return; } while(p) stk[++ tp] = p%10, p/=10; while(tp) putchar(stk[tp--] + '0'); putchar(' '); } const LL mod=1e9+7; const double PI=acos(-1.0); const int inf=1e9; const int N=2e6+10; const int maxn=500+10; const double eps=1e-8; LL get_sg(LL x) { if(x%2==0)return x/2; return get_sg(x/2); } int main() { int t; read(t); while(t--) { int n; LL ans=0,a; read(n); For(i,1,n) { read(a); ans^=get_sg(a); } if(ans)printf("YES "); else printf("NO "); //printf("%s ",ans ? "YES":"NO"); } return 0; }