POJ 1704 Georgia and Bob
2012-03-09 17:55
288 查看
POJ_1704
这个是经典的staircase nim游戏,在王晓珂的《解析一类组合问题》里面有提到过。
如果我们把相邻两个棋子之间以及最左边棋子和墙壁之间的棋子的数量看做每个阶梯上硬币的数目的话,这样就等效成staircase nim游戏,推荐一个讲解得比较清晰的博客:http://blog.sina.com.cn/s/blog_7fc44ee70100t9wr.html。
这个是经典的staircase nim游戏,在王晓珂的《解析一类组合问题》里面有提到过。
如果我们把相邻两个棋子之间以及最左边棋子和墙壁之间的棋子的数量看做每个阶梯上硬币的数目的话,这样就等效成staircase nim游戏,推荐一个讲解得比较清晰的博客: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(a[0]), cmp); } void solve() { int i, j, k, ans = 0; a = 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; }
相关文章推荐
- POJ 1704 Georgia and Bob [阶梯Nim]
- poj_Georgia and Bob_1704
- POJ 1704 Georgia and Bob
- POJ 1704 Georgia and Bob(nim变型)
- POJ 1704 Georgia and Bob【博弈】
- poj1704 Georgia and Bob博弈论
- [POJ1704]Georgia and Bob
- POJ 1704 Georgia and Bob【博弈】
- poj&nbsp;1704&nbsp;Georgia&nbsp;and&nbsp;Bob(博奕)
- POJ - 1704 Georgia and Bob
- POJ1704 Georgia and Bob(博弈)
- Georgia and Bob POJ 1704
- POJ1704 Georgia and Bob Nim阶梯博弈
- POJ 1704 Georgia and Bob【Nim博弈】
- POJ 1704 Georgia and Bob(阶梯博弈)
- POJ 1704 Georgia and Bob
- POJ 1704 Georgia and Bob [博弈]
- poj1704 Georgia and Bob(Nim变形:阶梯博弈)
- POJ 1704 Georgia and Bob(阶梯博弈+证明)
- poj1704 Georgia and Bob(阶梯博弈)