传送门

题意:

nim游戏,多了一种操作:将一堆分成两堆


 

Multi-SG游戏规定,在符合拓扑原则的前提下,一个单一游戏的后继可以为多个单一游戏。

仍然可以使用$SG$函数,分成多个游戏的后继$SG$值为多个游戏的异或和

然后本题规模很大,手动打一下表,发现$\mod 4=3$ 时$sg(x)=x+1$,$\mod 4=0$ 时$sg(x)=x-1$,其他不变

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
const int N=1e6;
inline int read(){
    char c=getchar();int x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}

int n;
inline int cal(int a){
    int t=a%4;
    return t==0 ? a-1 : (t==3 ? a+1 : a);
}
int main(){
    freopen("in","r",stdin);
    int T=read();
    while(T--){
        n=read();
        int sg=0;
        for(int i=1;i<=n;i++) sg^=cal(read());
        if(sg) puts("Alice");
        else puts("Bob");
    }
}

 

相关文章:

  • 2021-11-09
  • 2022-01-29
  • 2021-09-24
  • 2021-07-31
  • 2021-05-22
  • 2022-12-23
  • 2022-01-25
  • 2021-09-10
猜你喜欢
  • 2021-11-19
  • 2021-09-08
  • 2022-02-11
  • 2022-12-23
  • 2021-12-12
  • 2022-12-23
相关资源
相似解决方案