Test instructions: For n heap of stones, each pile of several, two people in turn, each operation in two steps, the first step from a heap to remove at least one, the second step (can be omitted) to the heap of the remaining stones part of the other heap.
Really good ♂ problem, code is not long is good ♂ problem.
First of all, consider two piles of the same stone, the initiator must lose, because if I operate the first pile, then the second pile can also make a symmetric decision.
In fact, other circumstances, must be the initiator win.
First case: Odd heap.
We can assign the maximum heap of pebbles to the other heaps so that they are 22 paired, as shown in:
Obviously, the red part of the cliff will not exceed the height of the fifth stone.
Second case: even case
We can pair the largest heap with the smallest one, and the rest of the pile will be matched with the n-2 heap of stones.
Emma:
1#include <iostream>2#include <cstdio>3#include <cstring>4#include <cmath>5#include <string>6#include <algorithm>7 intn,f[205],x;8 intMain () {9 while(SCANF ("%d", &n) &&N) {Ten intCnt=0; OneMemset (F,0,sizeoff); A for(intI=1; i<=n;i++){ -scanf"%d",&x); - if(!f[x]) cnt++,f[x]=1; the ElseCNT--, f[x]=0; - } - if(!cnt) printf ("0\n"); - Elseprintf"1\n"); + } -}
poj1740 A New Stone Game