Test instructions: Multiple sets of data, one first n for each set of data, and then the number of n heap stones.
Two people take turns operation, each can throw a K stone (K∈[1,xi]) from a certain quantity of the stone heap of Xi, then the remaining xi-k, can divide G stone randomly to other heap (cannot build out of thin air, g∈ (0,xi-k)).
Exercises
First, the equilibrium state is constructed:
There are even heaps, and can be paired 22.
This can be understood as the initiator play a bit, the other can have the same coping strategies. (The brain is just a little bit, this is not a difficult teenager)
So how to construct a balance state?
Consider if the total number is odd, then there is.
Then if the total number is even, then there are two graphs.
We'll sort the stones first, then the highest one on the left.
Figure two is the pairing method. (It's actually very water.)
But if the beginning is balanced, then no recruit, the initiator can only lose.
Well, you can only say that.
OK, you can look at the code:
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #define N 15using Namespace Std;int stone[n],n;int Main () {//freopen ("test.in", "R", stdin), int i,j,k;while (scanf ("%d", &n), N) {for (i =1;i<=n;i++) scanf ("%d", &stone[i]), if (n&1) puts ("1"), else {sort (stone+1,stone+n+1); bool Flag=1;for (i=1; i<n;i+=2) flag&= (stone[i]==stone[i+1]), if (flag) puts ("0"); else puts ("1");}} return 0;}
"POJ1740" A New Stone Game Construction Games