Reprint Please specify source: http://blog.csdn.net/vmurder/article/details/42671843
In fact, I just feel that the original traffic is a bit more uncomfortable than unauthorized piracy 233 ...
Test instructions: The same as Nim game, but who can not operate, who wins.
Theorem:
Nim game rules take the last stone to lose
Scope of application: for any one ANTI-SG
Game, when the situation of all the single game
The SG value is 0 o'clock and the game is over.
(1) Sg==0, there is a single game of sg>1. Unbeaten
(2) Sg!=0, there is a single game of sg>1. Sheng
(3) Sg==0, no single game of sg>1. Sheng
(4) Sg!=0, no single game of sg>1. Unbeaten
Code:
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace Std;
int main ()
{
int t,n,sg,x,k;
For (scanf ("%d", &t); t--;)
{
scanf ("%d", &n);
for (k=sg=0;n--;)
{
scanf ("%d", &x);
K^=x,sg=max (SG,X);
}
if (k) {
if (sg>1) puts ("John");
Else puts ("Brother");
}
else {
if (sg<2) puts ("John");
Else puts ("Brother");
}
}
return 0;
}
"POJ3480" John game anti-sg misère rules Nim game