codeforces 1370C. Number Game Solution
Solution in C++:
///La ilaha illellahu muhammadur rasulullah
///******Bismillahir-Rahmanir-Rahim******///
///Abul Hasnat Tonmoy
///Department of CSE,23rd batch
///Islamic University,Bangladesh
- #include <bits/stdc++.h>
- using namespace std;
- bool is_prime( int n)
- {
- for(int i = 2; i <=sqrt(n); i++)
- {
- if(n%i==0)
- return false;
- }
- return true;
- }
- int main()
- {
- int t,n,s;
- cin>>t;
- while(t--)
- {
- cin>>n;
- if(n==1)
- {
- cout << "FastestFinger" << endl;
- }
- else if(n==2)
- cout << "Ashishgup" << endl;
- else if(n%2==1&& n>2)
- {
- cout << "Ashishgup" << endl;
- }
- else
- {
- if((int)(n&(n-1))==0)
- cout << "FastestFinger" << endl;
- else if(n%4==0)
- cout << "Ashishgup" << endl;
- else if(is_prime(n/2)==true)
- cout << "FastestFinger" << endl;
- else
- cout << "Ashishgup" << endl;
- }
- }
- }
No comments