Poj_1704
This is a classic staircase Nim game, which was mentioned in Wang Xiaoke's "Analysis of A Class of combinations.
If we regard the number of adjacent pawns between the leftmost pawns and the wall as the number of coins on each step, it is equivalent to the staircase Nim game, we recommend a clear blog: http://blog.sina.com.cn/s/blog_7fc44ee70100t9wr.html.
# Include <stdio. h>
# Include < String . H>
# Include <stdlib. h>
# Define Maxd 1010
Int A [maxd], M, N;
Int CMP (Const Void * _ P, Const Void * _ Q)
{
Int * P = ( Int *) _ P, * q = ( Int *) _ Q;
Return * Q-* P;
}
Void Init ()
{
Int I, J, K;
Scanf (" % D " , & N );
For (I = 0 ; I <n; I ++)
Scanf ( " % D " , & A [I]);
Qsort (A, N, Sizeof ([ 0 ]), CMP );
}
Void Solve ()
{
Int I, J, K, ANS = 0 ;
A [n] = 0 ;
For (I = 0 ; I <n; I + = 2 )
Ans ^ = A [I]-A [I + 1 ]- 1 ;
If (ANS)
Printf ( " Georgia will win \ n " );
Else
Printf ( " Bob will win \ n " );
}
Int Main ()
{
Int T;
Scanf ( " % D " , & T );
While (T --)
{
Init ();
Solve ();
}
Return 0 ;
}