代码:
#include<bits/stdc++.h>
#define int long long
#define K 10000005
using namespace std;
int n,f[K],pre[K],cnt;
bool st[K];
void init(int n){
f[1]=1;
for(int i=2;i<=n;i++){
if(!st[i]){
pre[++cnt]=i;
if(i!=2)f[i]=cnt;
}
for(int j=1;j<=cnt&&pre[j]*i<=n;j++){
st[pre[j]*i]=1;
if(!(i%pre[j])){
f[i]=f[pre[j]];
break;
}
}
}
}
void solve(int cs){
cin>>n;
int res=0;
for(int i=1;i<=n;i++){
int x;
cin>>x;
res^=f[x];
}
cout<<(res==0?"Bob\n":"Alice\n");
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
init(10000000);
int T;
cin>>T;
for(int cs=1;cs<=T;cs++){
solve(cs);
}
return 0;
}
在第三个点上WA