Codeforces Round #651 (Div. 2) C. Number Game

题目链接

思路:奇数A必赢,1,2特判,偶数时,如果有奇数因子,并且除去奇数因子后不为2那么A必赢

#include 
#include 
#include 
#include 
#include
#include
using namespace std;
typedef long long ll;
#define SIS std::ios::sync_with_stdio(false)
#define space putchar(' ')
#define enter putchar('\n')
typedef pair<int,int> PII;
const int mod=1e4+7;
const int N=2e6+10;
const int inf=0x7f7f7f7f;


ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}

ll lcm(ll a,ll b)
{
    return a*(b/gcd(a,b));
}

template <class T>
void read(T &x)
{
    char c;
    bool op = 0;
    while(c = getchar(), c < '0' || c > '9')
        if(c == '-')
            op = 1;
    x = c - '0';
    while(c = getchar(), c >= '0' && c <= '9')
        x = x * 10 + c - '0';
    if(op)
        x = -x;
}
template <class T>
void write(T x)
{
    if(x < 0)
        x = -x, putchar('-');
    if(x >= 10)
        write(x / 10);
    putchar('0' + x % 10);
}
int cnt=0;
int vis[N],prim[N];
int  judge(int x)
{
    for(int i=2;i<=sqrt(x);i++)
    {
        if(x%i==0) return 0;
    }
    return 1;

}



int main()
{
   SIS;
   int t;
   cin>>t;
   while(t--)
   {
      int n;
      cin>>n;


      if(n==1)
      {
          cout<<"FastestFinger"<<endl;continue;
      }
      if(n%2!=0||n==2)
      {
           cout<<"Ashishgup"<<endl;continue;
      }
      else
      {
          int flag=0;
          int x=sqrt(n);
          int even=0,odd=0;
          for(int i=2;i<=x;i++)
          {
              if(n%i!=0)continue;
              if(i%2!=0&&(n/i)!=2)flag=1;
              if(n/i%2!=0&&i!=2)flag=1;
          }
          if(flag)
          cout<<"Ashishgup"<<endl;
          else
          cout<<"FastestFinger"<<endl;
      }

   }

    return 0;
}

你可能感兴趣的:(CF)