UVA-11892 (combo game)

Source: Internet
Author: User

Test instructions

Give n heap of stones, each pile of AI, each time can take any number of stones in each heap; But the last one did not take the whole bunch away, then the next person will be in that heap to take;

Ideas:

Every time I get this heap, we have one strategy left.

AC Code:

#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include < cmath>//#include <bits/stdc++.h> #include <stack>using namespace std; #define for (i,j,n) for (int i=j;i <=n;i++) #define MST (SS,B) memset (ss,b,sizeof (ss)); typedef long LONG ll;template<class t> void Read (T&num)    {char CH; bool F=false; For (Ch=getchar (); ch< ' 0 ' | | Ch> ' 9 ';    f= ch== '-', Ch=getchar ()); for (num=0;    ch>= ' 0 ' &&ch<= ' 9 '; num=num*10+ch-' 0 ', Ch=getchar ()); F && (num=-num);}    int stk[70], tp;template<class t> inline void print (T p) {if (!p) {puts ("0"); return;}    while (p) stk[++ TP] = p%10, p/=10;    while (TP) Putchar (stk[tp--] + ' 0 '); Putchar (' \ n ');} Const LL Mod=1e9+7;const double Pi=acos ( -1.0); const int INF=1E9;CONST int N=2e6+10;const int Maxn=500+10;const double eps=        1e-8;int Main () {int t;        Read (t);            while (t--) {int n,a,num=0;            Read (n); For (I,1,n) {read (a);            if (a==1) num++;                } if (num==n) {if (n%2) printf ("poopi\n");            else printf ("piloop\n");         } else printf ("poopi\n");  } return 0;}

  

UVA-11892 (combo game)

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.