HDU - 6892(尼姆博弈)
90nwyn
2020-10-07 13:14:02
[题目链接](https://vjudge.net/problem/HDU-6892)
------------
------------
```cpp
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int M=4e4;
int n,prime[M+5],tot,vis[M+5];
void init()
{
for(int i=2;i<=M;i++)
{
if(!vis[i])prime[++tot]=i;
for(int j=1;j<=tot&&i*prime[j]<=M;j++)
{
if(i%prime[j]==0)
{
vis[i*prime[j]]=1;
break;
}
vis[i*prime[j]]=1;
}
}
}
int main()
{
int T;scanf("%d",&T);
init();
while(T--)
{
scanf("%d",&n);
int sum=0;
for(int i=1;i<=n;i++)
{
int l;scanf("%d",&l);
int c=0;
for(int j=1;j<=tot&&prime[j]<=l;j++)
while(l%prime[j]==0)
{
l/=prime[j];
if(j==1)c=1;
else c++;
}
if(l>1)c++;
sum^=c;
}
if(sum)printf("W\n");
else printf("L\n");
}
return 0;
}
```