题意:nim游戏。加上限制每次不得取走超过当前堆一半的石子

1 ≤ N ≤ 100,1 ≤ ai ≤ 2 ∗ 1018

分析:由于ai过大。所以我们采用SG函数递推找规律。

(详见代码)

#include<cstdio>
using namespace std;
typedef long long ll;
int T,n;ll x,S;
ll GetSG(ll x){
    return x&1?GetSG(x>>1):x>>1;
}
int main(){
    for(scanf("%d",&T);T--;){
        for(scanf("%d",&n),S=0;n--;){
            scanf("%lld",&x);
            S^=GetSG(x);
        }
        if(S) puts("YES");
        else puts("NO");
    }
    return 0;
}

 

相关文章:

  • 2021-07-29
  • 2021-11-18
  • 2021-07-15
  • 2021-07-15
  • 2022-02-09
  • 2021-07-26
  • 2021-07-20
  • 2022-12-23
猜你喜欢
  • 2021-05-29
  • 2021-12-06
  • 2021-08-29
  • 2021-08-14
  • 2021-12-02
  • 2022-12-23
  • 2021-06-10
相关资源
相似解决方案