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;}