Codeforces 1382B - Sequential Nim Solution

  ///La ilaha illellahu muhammadur rasulullah

///******Bismillahir-Rahmanir-Rahim******///

///AH Tonmoy

///Department of CSE,23rd batch

    ///Islamic University,Bangladesh

    1. #include<iostream>
    2. using namespace std;
    3. int main()
    4. {
    5. int n,c,i,t;
    6. cin>>t;
    7. while(t--)
    8. {
    9. c=0;
    10. cin>>n;
    11. int a[n+9];
    12. for(i=0; i<n; i++)
    13. cin>>a[i];
    14. for(i=0; i<n; i++)
    15. {
    16. if(a[i]==1)
    17. c++;
    18. else
    19. break;
    20. }
    21. if(c==n)
    22. c--;
    23. if(c%2==1)
    24. cout<<"Second"<<endl;
    25. else
    26. cout<<"First"<<endl;
    27. }
    28. }

    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.