先打个表冷静一下
#include<map> #include<set> #include<cmath> #include<queue> #include<stack> #include<vector> #include<cstdio> #include<cassert> #include<iomanip> #include<cstdlib> #include<cstring> #include<iostream> #include<algorithm> #define pi acos(-1) #define ll long long #define mod 1000000007 #define ls l,m,rt<<1 #define rs m+1,r,rt<<1|1 #pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; const double g=10.0,eps=1e-9; const int N=1000+10,maxn=111117,inf=11111; int f[N],sg[N],Hash[N];//f是可以取走的石子书 void getsg(int n) { memset(Hash,0,sizeof Hash); for(int i=0;i<n;i++) Hash[sg[i]]=1; for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) if(i+j==n) Hash[sg[i]^sg[j]]=1; for(int i=0;;i++) if(!Hash[i]) { sg[n]=i; break; } cout<<n<<" "<<sg[n]<<endl; } int main() { ios::sync_with_stdio(false); cin.tie(0); for(int i=1;i<=100;i++) getsg(i); return 0; }
可以看出sg【i】=i;i%4==1||2
sg[i]=i+1,i%4==3
sg[i]=i-1,i%4==4
#include<map> #include<set> #include<cmath> #include<queue> #include<stack> #include<vector> #include<cstdio> #include<cassert> #include<iomanip> #include<cstdlib> #include<cstring> #include<iostream> #include<algorithm> #define pi acos(-1) #define ll long long #define mod 1000000007 #define ls l,m,rt<<1 #define rs m+1,r,rt<<1|1 #pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; const double g=10.0,eps=1e-9; const int N=1000+10,maxn=111117,inf=11111; int main() { ios::sync_with_stdio(false); cin.tie(0); int t,n,a; cin>>t; while(t--){ cin>>n; int ans; for(int i=0;i<n;i++) { cin>>a; if(a%4==3)a++; else if(a%4==0)a--; if(i==0)ans=a; else ans=ans^a; } if(!ans)cout<<"Bob"<<endl; else cout<<"Alice"<<endl; } return 0; }
时间: 2024-10-13 12:51:54