把相邻的两个棋子间的空隙看成一堆石子,当一对石子间没有空隙时视为相应堆数的石子被取完,考虑奇数个时要把最左边的等效出一个棋子来配成偶数个,然后转化成Nim游戏求解
//POJ-1704.cpp
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <cctype>
#include <algorithm>
#include <iostream>
#include <string>
#include <stack>
#include <map>
#include <set>
#include <queue>
#include <utility>
#include <vector>
#include <bitset>
#include <functional>
using namespace std;
//const double pai = acos(-1.0);
const double pai = 3.14159265358979323846;
const int INF = 0x3f3f3f3f;
typedef long long love_live;
int arr[1117], pos[1117];
bool cmp(int a, int b){
return a > b;
}
void init(){
memset(arr, 0, sizeof(arr));
memset(pos, 0, sizeof(pos));
return ;
}
int main(int argc, char const *argv[]) {
#ifndef ONLINE_JUDGE
// freopen("output", "w", stdout);
freopen("input", "r", stdin);
#endif
int n, m, i, j, k;
int t, p;
while(scanf("%d", &t) != EOF){
while(t--){
scanf("%d", &n);
init();
for(i = 0; i < n; ++i){
scanf("%d", &pos[i]);
}
sort(pos, pos + n, cmp);
// for(i = 0; i < n; i++){
// cout << pos[i] << " ";
// }
// cout << endl;
k = 0;
if(n % 2 == 0){
for(i = 0; i < n; i += 2){
arr[k++] = pos[i] - pos[i + 1] - 1;
}
k--;
}
else{
pos[n + 1] = 0;
for(i = 0; i < n; i+= 2){
arr[k++] = pos[i] - pos[i + 1] - 1;
}
k--;
}
// for(i = 0; i <= k; i++){
// cout << arr[i] << " ";
// }
// cout << endl;
int ans = 0;
for(i = 0; i <= k; ++i){
ans ^= arr[i];
}
// cout << ans << endl;
if(ans == 0){
printf("Bob will win\n");
}
else{
printf("Georgia will win\n");
}
}
}
return 0;
}