Ultraviolet A 11892-ENimEN (simple game)

Source: Internet
Author: User

 


Q: There are n piles of stones, and the number of each heap is ai. You can take any non-0 stones in a pile each time and win the final stone.
The new condition is that each user can only retrieve the heap obtained by the opponent, unless the opponent completes the heap.

Question:
For simple reasoning, consider 1 ~ N heap, each heap is 1
1 first, 1 after, 1 1 first, 1 1 1 after ,... Alternate
If the value is not 1, the value of non-1 is set to x.
X first,
1 x-> 1 1 first, x-> 1 x-> x first
1 1 x-> 1 1 first, 1 x-> 1x1-> 1 x first, x-> x 1-> x first
...
It can be found that, except for the case where all data is set to 1, all data can be first-handed based on known conditions.

 


AC code:

 

#include <iostream>   #include <cstdio>   #include <cstring>   #include <string>   #include <cstdlib>   #include <cmath>   #include <vector>   #include <list>   #include <deque>   #include <queue>   #include <iterator>   #include <stack>   #include <map>   #include <set>   #include <algorithm>   #include <cctype>   #include <ctime>   using namespace std;    typedef long long LL;  const int N=100005;  const int INF=0x3f3f3f3f;  const double PI=acos(-1.0);    int main()  {      int i,T;      cin>>T;      while(T--)      {          int a,n,f=0;          scanf("%d",&n);          for(i=0;i<n;i++)          {              scanf("%d",&a);              if(a!=1)                  f=1;          }          if(f==0&&n%2==0)              puts("piloop");          else              puts("poopi");      }      return 0;  }  #include <iostream>#include <cstdio>#include <cstring>#include <string>#include <cstdlib>#include <cmath>#include <vector>#include <list>#include <deque>#include <queue>#include <iterator>#include <stack>#include <map>#include <set>#include <algorithm>#include <cctype>#include <ctime>using namespace std;typedef long long LL;const int N=100005;const int INF=0x3f3f3f3f;const double PI=acos(-1.0);int main(){    int i,T;    cin>>T;    while(T--)    {        int a,n,f=0;        scanf("%d",&n);        for(i=0;i<n;i++)        {            scanf("%d",&a);            if(a!=1)                f=1;        }        if(f==0&&n%2==0)            puts("piloop");        else            puts("poopi");    }    return 0;}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.