POJ 1704 Topics Link
There are the following theorems about ladder game :
Treat all odd steps as n heap stones, make nim, move stones from odd heaps to even heaps as take stones, similarly, when the XOR value is not 0 (self-interest), the initiator will win.
Proof of theorem See this blog: http://blog.csdn.net/kk303/article/details/6692506
The following is the AC code for POJ 1704:
//The pawn can only go left (the leftmost line), can walk any Dogger (>=1)//and the pawn cannot cross the pawn in front of it (the pawn on its left)//each of the squares has a maximum of one piece, indicating that the piece can not go to the position of another piece//convert to Nim: Put the input position in order to calculate the spacing between two adjacent points, the spacing is the maximum number of steps to walk K, as a bunch of k stones//then iterate from the largest position (because of the right), calculating the Nim XOR value of the odd heap#include <iostream>#include<cstdio>#include<algorithm>using namespacestd;intMain () {intT; scanf ("%d",&t); while(t--) { intsum=0, n,a[1005],b[1005]; scanf ("%d",&N); a[0]=0; for(intI=1; i<=n;i++) scanf ("%d",&A[i]); Sort (A,a+n+1); for(intI=1; i<=n;i++) B[i]=a[i]-a[i-1]-1; intCnt=0; for(intI=n;i>0; i--) {CNT++; if(cnt&1) Sum^=B[i]; } if(sum) printf ("Georgia'll win\n"); Elseprintf"Bob would win\n"); } return 0;}
POJ 1704 Georgia and Bob (ladder game + proof)