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

    1. #include <bits/stdc++.h>
    2. using namespace std;
    3. bool is_prime( int n)
    4. {
    5. for(int i = 2; i <=sqrt(n); i++)
    6. {
    7. if(n%i==0)
    8. return false;
    9. }
    10. return true;
    11. }
    12. int main()
    13. {
    14. int t,n,s;
    15. cin>>t;
    16. while(t--)
    17. {
    18. cin>>n;
    19. if(n==1)
    20. {
    21. cout << "FastestFinger" << endl;
    22. }
    23. else if(n==2)
    24. cout << "Ashishgup" << endl;
    25. else if(n%2==1&& n>2)
    26. {
    27. cout << "Ashishgup" << endl;
    28. }
    29. else
    30. {
    31. if((int)(n&(n-1))==0)
    32. cout << "FastestFinger" << endl;
    33. else if(n%4==0)
    34. cout << "Ashishgup" << endl;
    35. else if(is_prime(n/2)==true)
    36. cout << "FastestFinger" << endl;
    37. else
    38. cout << "Ashishgup" << endl;
    39. }
    40.  
    41. }
    42. }

    No comments

    Most View Post

    Recent post

    Codeforces Round 925 (Div. 3) 1931D. Divisible Pairs Solution

        Problem Link  :   https://codeforces.com/contest/1931/problem/D S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. ...

    Powered by Blogger.