Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef pair<int,int> ii;
- const int MaxN = 1e9 + 2e2;
- const int N = (int)sqrt(MaxN) + 1;
- map<ii ,int> Memo;
- vector<int> Div;
- int n;
- int calc(int n ,bool T) {
- // T = Ashishgup
- // !T = FastestFinger
- int &Re = Memo[ {n,T} ];
- if(Re != 0) return Re;
- if( n % 2 && T ) return Re = +1;
- if( n % 2 && !T ) return Re = -1;
- int Res = -1;
- for(auto i : Div){
- if( i <= n && n % i == 0) {
- if( (n / i) % 2 == 0 ){
- Res = calc(n / i ,!T);
- if( Res == 1 )
- break;
- }
- }
- }
- if( Res == -1 ) Res = calc(n-1 ,!T);
- return Re = Res;
- }
- void Solve(){
- scanf("%d" ,&n);
- for(int i=2 ; i <= (int)sqrt(n) + 1 ; i ++){
- if(n % i == 0) {
- if( i & 1 )
- Div.push_back(i);
- if( (n / i) & 1 && (n / i) > 1 )
- Div.push_back(n/i);
- }
- }
- bool Ashishgup = true;
- bool FastestFinger = false;
- Memo[ {1 ,Ashishgup} ] = -1;
- Memo[ {1 ,FastestFinger} ] = +1;
- int Ans = calc(n ,1);
- puts( (Ans > 0) ? "Ashishgup" : "FastestFinger" );
- Div.clear();
- }
- int main() {
- int Tc; scanf("%d" ,&Tc);
- while( Tc-- ) Solve();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement