Http://poj.org/problem? Id = 1704
Put the array upside down (17 14 12 9 7 6 5 1), regard the spacing of adjacent pieces as a pile of stones (2 1 2 0 0 3 ), the operation in the question is to put n of the last pile of stones into the previous pile of stones, which is converted into a tiered game. It's okay to use the tiered game solution for odd bit or odd bit.
In other blogs, we also see a solution that groups two groups from the backend and adds a zero node to the front of an odd vertex. Consider the distance between two nodes as a pile of stones.
1. If the opponent moves the first of the two, the last one will certainly be able to move the same number of locations.
2. If the opponent moves the last one of the two, it is equivalent to taking N from the pile of stones.
Isn't that a tiered game? The operation on the even heap can be ignored. The odd heap is an exception or a solution. Why does it look amazing...
Code:
# Include <cstdio>
# Include <cstdlib>
Int data [1001];
Int CMP (const void * a, const void * B ){
Return * (int *) A <* (int *) B? -1: 1;
}
Int main (){
Int t, n, I, j, sum;
Scanf ("% d", & T );
While (t --){
Sum = 0;
Scanf ("% d", & N );
Data [0] = 0;
For (I = 1; I <= N; I ++)
Scanf ("% d", & Data [I]);
Qsort (data, n + 1, sizeof (data [0]), CMP );
For (I = N; I> 0; I-= 2)
Sum ^ = (data [I]-data [I-1]-1 );
If (SUM) printf ("Georgia will win \ n ");
Else printf ("Bob will win \ n ");
}
Return 0 ;}