POJ 1704 Georgia and Bob [阶梯Nim]
题意:
每次可以向左移动一个棋子任意步,不能跨过棋子
很巧妙的转化,把棋子间的空隙看成石子堆
然后裸阶梯Nim
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> using namespace std; typedef long long ll; const int N=1005; inline int read(){ char c=getchar();int x=0,f=1; while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();} while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();} return x*f; } int n,a[N]; int main(){ //freopen("in","r",stdin); int T=read(); while(T--){ n=read(); for(int i=1;i<=n;i++) a[i]=read(); sort(a+1,a+1+n); int sg=0; for(int i=n;i>=1;i-=2) sg^= a[i]-a[i-1]-1; puts(sg ? "Georgia will win" : "Bob will win"); } }
Copyright:http://www.cnblogs.com/candy99/