POJ 1704 Georgia and Bob (Nim游戏变形)
来源:互联网 发布:python 开源项目 编辑:程序博客网 时间:2024/05/02 04:18
题目:http://poj.org/problem?id=1704
思路:Nim游戏策略,做如下转换,如果N是偶数,则两两配对,将两个数之间的格子数(距离)看做成这一堆石头的数量。
如果N是奇数,则将一个0的格子放在第一个。
代码:
#include<iostream>#include<algorithm>using namespace std;const int MAXN=10000+2;int N,P[MAXN];int main(){int t;cin>>t;while(t--){cin>>N;for(int i=0; i<N; i++){cin>>P[i];}if(N&1==1) P[N++]=0;sort(P,P+N);int res=0; for(int i=0; i+1<N; i+=2) { res ^= (P[i+1]-P[i]-1); } if(res==0) cout<<"Bob will win"<<endl; else cout<<"Georgia will win"<<endl;}return 0;}
- POJ 1704 Georgia and Bob (Nim游戏变形)
- POJ 1704 Georgia and Bob (博弈 Nim游戏变形)
- POJ 1704 Georgia and Bob <Nim变形>
- POJ 1704(Georgia and Bob-Nim博弈)
- POJ 1704 Georgia and Bob(nim博弈论)
- poj 1704Georgia and Bob nim博弈
- POJ 1704 Georgia and Bob (Nim博弈)
- POJ 1704 Georgia and Bob(nim变型)
- POJ 1704 Georgia and Bob (Nim博弈)
- [POJ 1704] Georgia and Bob (尼姆博弈变形)
- POJ 1704 Georgia and Bob(尼姆变形)
- Georgia and Bob(Nim游戏,只判断)
- POJ 1704 Georgia and Bob (博弈:Staircase Nim)
- POJ 1704-Georgia and Bob棋子移动(Nim博弈)
- POJ Georgia and Bob(Nim博弈)
- poj 1704 Georgia and Bob(博弈)
- POJ 1704 Georgia and Bob(博弈)
- POJ 1704 Georgia and Bob(博弈)
- linux 下vim编辑器用法
- socket阻塞与非阻塞,同步与异步、I/O模型
- 亲测 S3C2440 dnw下载驱动 win7_x64
- Java中sleep和wait的区别
- 类加载器Classloader
- POJ 1704 Georgia and Bob (Nim游戏变形)
- iOS7 UI改变总结
- ubuntu_hadoop 单机模式安装
- Running the Winsock Client and Server Code Sample
- delphi ord()
- javascript高效简洁代码的编写及优化技巧
- shell 13问
- 分布式系统架构的基本原则和实践
- java注解