poj 1704

来源:互联网 发布:情侣衣服 淘宝网 编辑:程序博客网 时间:2024/06/05 14:16
Georgia and Bob
Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 5011 Accepted: 1357

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

2
3
1 2 3
8
1 5 6 7 9 12 14 17

Sample Output

Bob will winGeorgia will win

Source

POJ Monthly--2004.07.18
题意:向左移动棋子,不可越过其他棋子。
分析:奇异局势必定是,两两棋子相邻为一组,前手移动左边的棋子,后手只需紧贴就可以了。所以无需考虑组合组之间的空隙,而组内棋子之间的距离相当于取石子
#include <cstdio>#include<string.h>#include<algorithm>using namespace std;int main(int argc, char *argv[]){int T,n,a[1011],b[1011],i,sum,k;scanf("%d",&T);while(T--){sum=0;scanf("%d",&n);for (i=0;i<n;i++)        scanf("%d",&a[i]);        sort(a,a+n);//这里就是错的地方,题目并没有说已经排好序      if (n%2==0)         {        k=0;        for (i=1;i<n;i=i+2)        {   b[k++]=a[i]-a[i-1]-1; //两个数字间的个数需要减一 }}else {k=1;b[0]=a[0]-1;for (i=2;i<n;i=i+2){b[k++]=a[i]-a[i-1]-1;//赋予K值保证B数组中是连续的 }}for (i=0;i<k;i++)        {     sum^=b[i];    }    if(sum) printf("Georgia will win\n");    else printf("Bob will win\n");}return 0;}

 
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 京东保价 发票怎么办 win7用户已锁定怎么办 电脑账户被锁定怎么办 win7状态不可用怎么办 电脑的本地连接不见了怎么办 win7电脑没有本地连接怎么办 win7字体换不了怎么办 电脑没系统了怎么办 电脑系统没有了怎么办 系统调用区域小怎么办 win8.1网络受限怎么办 电脑连wifi受限怎么办 鼠标不好用了怎么办 手机指纹不好使怎么办 手机录像不好使怎么办 手机1个卡不好使怎么办 手机收藏不好使怎么办 window10连不上网怎么办 电脑没有家庭组怎么办 usb共享网络出错怎么办 电脑共享有密码怎么办 win10连不上网怎么办 w10网络重置了怎么办 点击网络重置后怎么办? 电脑启动找不到硬盘怎么办 电脑开机找不到硬盘怎么办 电脑找不到宽带连接怎么办 电脑文件找不到了怎么办 电脑找不到手机热点怎么办 win7电脑没有网络适配器怎么办 手机计算机桌面找不到怎么办 手机忘记开锁密码怎么办 电脑没网感叹号怎么办 本地连接2没有了怎么办 电脑上找不到本地连接怎么办 网络无访问权限怎么办 电脑无网络访问怎么办 xp连不上网怎么办 xp系统本地连接不见了怎么办 电脑xp系统本地连接怎么办 xp系统本地连接失败怎么办