HDU 4315 Climbing the Hill [阶梯Nim]
题意:
和上题基本一样;山顶可以有多人,谁先把king放到山顶谁就胜
并不太明白
#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,k,a[N]; int main(){ //freopen("in","r",stdin); while(scanf("%d%d",&n,&k)!=EOF){ for(int i=1;i<=n;i++) a[i]=read(); if(k==1) {puts("Alice");continue;} int sg=0; if(k!=2) a[0]=-1; else a[0]=0; for(int i=n;i>=1;i-=2) sg^= a[i]-a[i-1]-1; puts(sg ? "Alice" : "Bob"); } }
Copyright:http://www.cnblogs.com/candy99/