标题:GCD Game
---------------------------------------------------------------------------------------------------------------------------------------vjudge提交链接
题解:
大佬链接:Viktoriae
代码:
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int N=1e7;
bool book[N+10];
int p[666666],num[N+10],cnt;
void getPrime_zhi()
{
for(int i=2;i<=N;i++)
{
if(!book[i]) p[++cnt]=i,num[i]=1;
for(int j=1;j<=cnt&&p[j]<=N/i;j++)
{
book[i*p[j]]=true;
num[i*p[j]]=num[i]+1;
if(i%p[j]==0) break;
}
}
}
int main()
{
getPrime_zhi();
int t;
scanf("%d",&t);
while(t--)
{
int n,x,ans=0;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%d",&x);
ans^=num[x];
}
if(ans) printf("Alice\n");
else printf("Bob\n");
}
return 0;
}