Test instructions
There are m stacks of poker on the table, and the number of cards per pile is ni (i=1 ... M);
Two people take turns, each step can choose a bunch and take away any cards;
The poker on the table is all taken out, then the game is over, and the last person to pick the card is the winner.
Exercises
Nimbo Game (Nimm game)
First of all heap Nim-sum = N1 ^ N2 ^ ... NM
And then
Res =nim-sum ^ Ni
If res < NI, then the initiator player as long as the first step from the Ni heap to take ni-res, then the remaining situation nim-sum = 0,
That is, for the rest of the situation is a must-fail state. Then this is a winning scheme.
There is at most one method for each heap operation to defeat the required point (nim-sum = 0)
#include <cstdio> #include <cstring> #include <algorithm>using namespace Std;int a[200];int main () { int n; while (~SCANF ("%d", &n) &&n) { int sum = 0; for (int i=0; i<n; ++i) { scanf ("%d", &a[i]); Sum ^= a[i]; } int ans = 0; for (int i=0; i<n; ++i) if (A[i] > (sum^a[i])) ans++; printf ("%d\n", ans); } return 0;} <span style= "font-family:arial, Helvetica, Sans-serif;" ><span style= "White-space:normal;" ></span></span>
hdu1850 Being a good boy in Spring Festival, Nim game (Mimm game), Min sum