题解

感觉挺神奇的

我们把石子从后往前相邻的两个两两配对,这样他们之间的空格就相当于一堆石子

而配对后左边棋子移动,右边棋子也一定可以跟上取

转化成简单的nim游戏,最后只要看转化出的这(N - 1)/2 + 1堆石子异或起来等于0

代码

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
//#define ivorysi
#define MAXN 1005
#define eps 1e-8
using namespace std;
typedef long long int64;
typedef double db;
int N,T;
int a[MAXN];
void Solve() {
scanf("%d",&N);
for(int i = 1 ; i <= N ; ++i) {
scanf("%d",&a[i]);
}
sort(a + 1,a + N + 1);
int ans = 0;
for(int i = N ; i >= 1 ; i -= 2) {
ans ^= a[i] - a[i - 1] - 1;
}
if(!ans) puts("Bob will win");
else puts("Georgia will win");
}
int main() {
#ifdef ivorysi
freopen("f1.in","r",stdin);
#endif
scanf("%d",&T);
while(T--) {
Solve();
}
}

【POJ】1704.Georgia and Bob的更多相关文章

  1. 【POJ】1704 Georgia and Bob(Staircase Nim)

    Description Georgia and Bob decide to play a self-invented game. They draw a row of grids on paper, ...

  2. poj 1704 Georgia and Bob(阶梯博弈)

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

  3. 【POJ】1067 取石子游戏(博弈论)

    Description 有两堆石子,数量任意,可以不同.游戏开始由两个人轮流取石子.游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子:二是可以在两堆中同时取走相同数量的石子.最后 ...

  4. poj 1704 Georgia and Bob(阶梯博弈)

    Georgia and Bob Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 8656   Accepted: 2751 D ...

  5. poj 1704 Georgia and Bob (nim)

    题意: N个棋子,位置分别是p[1]...p[N]. Georgia和Bob轮流,每人每次可选择其中一个棋子向左移动若干个位置(不能超过前一个棋子,不能超出最左边[位置1]且不能不移) Georgia ...

  6. POJ 1704 Georgia and Bob(阶梯Nim博弈)

    Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 11357   Accepted: 3749 Description Geor ...

  7. [原博客] POJ 1704 Georgia and Bob

    题目链接题意:如图,Georgia和Bob在玩游戏.一个无限长的棋盘上有N个旗子,第i个棋子的位置可以用Pi表示.现在Georgia先走.每个人每一次可以把一枚棋子向左移动任意个格子,但是不能超越其他 ...

  8. hdu 4315 Climbing the Hill && poj 1704 Georgia and Bob阶梯博弈--尼姆博弈

    参考博客 先讲一下Georgia and Bob: 题意: 给你一排球的位置(全部在x轴上操作),你要把他们都移动到0位置,每次至少走一步且不能超过他前面(下标小)的那个球,谁不能操作谁就输了 题解: ...

  9. 【BZOJ】【1986】【USACO 2004 Dec】/【POJ】【2373】划区灌溉

    DP/单调队列优化 首先不考虑奶牛的喜欢区间,dp方程当然是比较显然的:$ f[i]=min(f[k])+1,i-2*b \leq k \leq i-2*a $  当然这里的$i$和$k$都是偶数啦~ ...

随机推荐

  1. C语言复习---判断素数

    一般 int main01() { ; scanf("%d", &a); n_sqrt = sqrt(a); ; i <= n_sqrt; i++) ) { flag ...

  2. COGS 1516. 棋盘上的车

    COGS 1516. 棋盘上的车 http://www.cogs.pro/cogs/problem/problem.php?pid=1516 ☆   输入文件:rook.in   输出文件:rook. ...

  3. MongoDB - Introduction to MongoDB, Databases and Collections

    MongoDB stores BSON documents, i.e. data records, in collections; the collections in databases. Data ...

  4. Elasticsearch技术解析与实战(一)基础概念及环境搭建

    序言 ES数据架构的主要概念(与关系数据库Mysql对比) 集群(cluster) 集群,一个ES集群由一个或多个节点(Node)组成,每个集群都有一个cluster name作为标识.一下是我们的4 ...

  5. 回调函数之基本的Promise

    在 JavaScript 中,所有的代码都是单线程的,所谓的回调函数就是为了处理一些异步的操作.而多层的回调函数嵌套是一种比较古老的处理方式,这种代码的弊端显而易见,结构混乱.代码冗余,而 Promi ...

  6. 希尔密码(Hill Cipher)的实现

    原理应该不用多讲了,自己百度就可以. C++实现: #include <iostream> #include <string> #include <memory.h> ...

  7. CodeForces 816B 前缀和

    To stay woke and attentive during classes, Karen needs some coffee! Karen, a coffee aficionado, want ...

  8. 61.volatile关键字

    volatile作用 volatile的作用是可以保持共享变量的可见性,即一个线程修改一个共享变量后,另一个线程能够读取到这个修改后的值. 先来看一个问题: 定义一个Task类 package com ...

  9. 在window 8 或windows2012 上用命令行安装framework3.5 方法

    找到对应操作系统安装目录的sources文件夹下的sxs文件夹,拷贝到本地电脑,如F:盘 根目录下 CMD(管理员身份)命令: dism.exe /online /enable-feature /fe ...

  10. mysql 数据范围总结

    MEDIUMINT 带符号的范围是-8388608到8388607,无符号的范围是0到16777215,使用3个字节. 一般情况下推荐使用 unsigned (无符号,即只接受正整数)