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

    RESTful APIs with CRUD Operations in Laravel 12| (2025)

      RESTful APIs serve as the foundation of modern web development. They follow a set of rules called Representational State Transfer (REST) t...

    Powered by Blogger.