思路:
分类讨论
如果n=1,那先手必败
如果n=2,那先手必胜
如果n是奇数,那只要除n就变成一,先手必胜
如果n是2的几次方,那先手只能减一变成奇数,那先手必败
最后n=2*W,如果W是质因子,那先手只要除W,先手必胜。否则W肯定为一个以上质因子相乘,先手不能减一,只能除,然后W的质因子中肯定不是全为2,所以把不是2的除掉,后手变成情况4,于是先手必胜
c o d e code code
#include<iostream>
#include<cstdio>
using namespace std;
int t, n;
bool check(int n)
{
for(int i=2; i<=29; i++)
if((1<<i)==n)
return 1;
return 0;
}
int main()
{
scanf("%d", &t);
while(t--)
{
scanf("%d", &n);
if(n==1)
printf("FastestFinger\n");
else if(n==2)
printf("Ashishgup\n");
else if(n%2==1)
printf("Ashishgup\n");
else if(check(n))
printf("FastestFinger\n");
else
{
int w=n/2, flag=0;
for(int i=2; i*i<=w; i++)
if(w%i==0)
{
flag=1;
break;
}
if(flag)
printf("Ashishgup\n");
else printf("FastestFinger\n");
}
}
return 0;
}