题意:有n堆石子,两个人拿,拿走最后的石子的人赢,poopi先拿,条件是,每个人必须从另外一个人最后拿过的石子堆中取石子,若那堆石子被拿没了,才可以自由地拿其他堆。要求每次拿的石子数不能为0。问谁赢。
分析:
1、若每堆石子个数都为1,很显然谁赢只取决于n。
2、
(1)若石子堆中有奇数堆石子个数为1,如
5 2 1 3 1 9 6 1
则先手poopi只需要每次先从个数不为1的石子堆中拿,并且一下拿走(该石子堆个数-1)个,另一个人只能拿走该石子堆剩下的最后一个石子。
如此反复,拿完所有个数不为1的石子堆后,就回到了(1),显然剩下奇数堆,先手赢。
(2)若石子堆中有偶数堆石子个数为1,如
5 2 1 3 1 9 1 6 1
则先手只需要先按照2.1的思路一直拿到还剩下一堆不为1的石子堆,此时,轮到先手,先手将这堆不为1的石子堆全部拿走,
则还剩偶数堆个数为1的石子堆,先手赢。
综上所述,先手赢。
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<iostream>
#include<sstream>
#include<iterator>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<list>
#define lowbit(x) (x & (-x))
const double eps = 1e-8;
inline int dcmp(double a, double b){
if(fabs(a - b) < eps) return 0;
return a > b ? 1 : -1;
}
typedef long long LL;
typedef unsigned long long ULL;
const int INT_INF = 0x3f3f3f3f;
const int INT_M_INF = 0x7f7f7f7f;
const LL LL_INF = 0x3f3f3f3f3f3f3f3f;
const LL LL_M_INF = 0x7f7f7f7f7f7f7f7f;
const int dr[] = {0, 0, -1, 1, -1, -1, 1, 1};
const int dc[] = {-1, 1, 0, 0, -1, 1, -1, 1};
const int MOD = 1e9 + 7;
const double pi = acos(-1.0);
const int MAXN = 20000 + 10;
const int MAXT = 10000 + 10;
using namespace std;
int a[MAXN];
int main(){
int T;
scanf("%d", &T);
while(T--){
int N;
scanf("%d", &N);
int cnt = 0;
for(int i = 0; i < N; ++i){
scanf("%d", &a[i]);
if(a[i] == 1) ++cnt;
}
if(cnt == N){
if(cnt & 1){
printf("poopi\n");
}
else{
printf("piloop\n");
}
continue;
}
printf("poopi\n");
}
return 0;
}