SG打表找规律
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
#define MAXN 10000
int sg[MAXN],visit[MAXN];
int getsg(int n)
{
int i,j;
if(sg[n]!=-)
return sg[n];
memset(visit,,sizeof(visit));
for(i=n-;i>=;i--)
visit[sg[i]]=;
for(i=;i<n;i++)
for(j=;j<n;j++)
if(n-i-j>)
visit[getsg(i)^getsg(j)^getsg(n-i-j)]=;
for(i=;i<=MAXN;i++)
if(!visit[i])
return sg[n]=i;
}
/*int main()
{
/**²âÊÔ´ò±í**/ /*memset(sg,-1,sizeof(sg));
for(int i=0; i<50; i++)
{
printf("sg[%d] = %d\n",i,getsg(i));
}
return 0;
}*/
int main()
{
int t,n,x;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
int ans=;
for(int i=;i<n;i++)
{
scanf("%d",&x);
if(x%==)
ans^=x-;
else if((x+)%==)
ans^=x+;
else
ans^=x;
}
if(!ans)
printf("Second player wins.\n");
else
printf("First player wins.\n");
}
return ;
}