zoukankan      html  css  js  c++  java
  • LA5059 Playing With Stones

    题意: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;
    }
  • 相关阅读:
    第四次作业
    第三次作业
    第二次作业。
    国庆作业。
    实验2-4
    实验2-3
    实验2-2
    实验2-1
    实验1-3
    实验 1-1
  • 原文地址:https://www.cnblogs.com/shenben/p/6650317.html
Copyright © 2011-2022 走看看