博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
poj 1704 Georgia and Bob(阶梯博弈)
阅读量:6860 次
发布时间:2019-06-26

本文共 2815 字,大约阅读时间需要 9 分钟。

Georgia and Bob
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 9363   Accepted: 3055

Description

Georgia and Bob decide to play a self-invented game. They draw a row of grids on paper, number the grids from left to right by 1, 2, 3, ..., and place N chessmen on different grids, as shown in the following figure for example: 
Georgia and Bob move the chessmen in turn. Every time a player will choose a chessman, and move it to the left without going over any other chessmen or across the left edge. The player can freely choose number of steps the chessman moves, with the constraint that the chessman must be moved at least ONE step and one grid can at most contains ONE single chessman. The player who cannot make a move loses the game. 
Georgia always plays first since "Lady first". Suppose that Georgia and Bob both do their best in the game, i.e., if one of them knows a way to win the game, he or she will be able to carry it out. 
Given the initial positions of the n chessmen, can you predict who will finally win the game? 

Input

The first line of the input contains a single integer T (1 <= T <= 20), the number of test cases. Then T cases follow. Each test case contains two lines. The first line consists of one integer N (1 <= N <= 1000), indicating the number of chessmen. The second line contains N different integers P1, P2 ... Pn (1 <= Pi <= 10000), which are the initial positions of the n chessmen.

Output

For each test case, prints a single line, "Georgia will win", if Georgia will win the game; "Bob will win", if Bob will win the game; otherwise 'Not sure'.

Sample Input

231 2 381 5 6 7 9 12 14 17

Sample Output

Bob will winGeorgia will win
/*poj 1704 Georgia and Bob(阶梯博弈)一行棋盘,每次可以将一个棋子往左边移动,但是不能跨越棋子每次移动时,和左边的间距变小了,与右边的间距变大可以等效于阶梯博弈,每次将一个台阶上的棋子往下移动。 本台阶石子变少,下一个台阶的石子边多转化一下就好了hhh-2016-08-02 21:26:32*/#include 
#include
#include
#include
#include
#include
typedef long long ll;#define lson (i<<1)#define rson ((i<<1)|1)using namespace std;const int maxn = 10000+10;int sg[maxn];int s[maxn];int n;void SG(int now){ if(sg[now] != -1) return ; int vis[maxn]; memset(vis,0,sizeof(vis)); for(int i = 0; i < n; i++) { int t = now-s[i]; if(t < 0) continue; SG(t); vis[sg[t]] = 1; } for(int i = 0;; i++) { if(!vis[i]) { sg[now] = i; break; } }}int main(){ int x,m; int a[maxn];// freopen("in.txt","r",stdin); int T; scanf("%d",&T); while(T--) { scanf("%d",&n) ; for(int i = 0; i < n; i++) { scanf("%d",&a[i]); } sort(a,a+n); int ans; if(n % 2 == 0) ans = 0; else ans = a[0]-1; for(int i = n-1; i > 0; i -= 2) { ans ^= (a[i] - a[i-1] -1); } if(ans) printf("Georgia will win\n"); else printf("Bob will win\n"); } return 0;}

  

转载于:https://www.cnblogs.com/Przz/p/5757427.html

你可能感兴趣的文章
给力分享新的ORM => Dapper( 转)
查看>>
【LeetCode】71. Simplify Path
查看>>
自定义View字段表头
查看>>
JavaScript大杂烩9 - 理解BOM
查看>>
数学图形(1.32) 鸡蛋
查看>>
MVC – 9.mvc整体请求流程
查看>>
Windows Phone本地数据库(SQLCE):11、使用LINQ查询数据库(翻译) (转)
查看>>
微软发布WP SDK8.0 新增语音、应用内支付等原生API
查看>>
关于Installshield里一些常见问题的解答—艾泽拉斯之海洋女神出品
查看>>
【BZOJ】1630: [Usaco2007 Demo]Ant Counting(裸dp/dp/生成函数)
查看>>
关于PCA算法的一点学习总结
查看>>
读书笔记之《习惯的力量》
查看>>
自己动手写操作系统--个人实践
查看>>
Aix6.1安装openssh
查看>>
成功让Eclipse更新ADT的方法
查看>>
第十章 基本数据结构——栈和队列
查看>>
解决SecureCRT中文显示乱码
查看>>
noip2014滚粗记
查看>>
如何安全实现“记住我”的功能
查看>>
把一件简单的事情做好你就不简单了
查看>>