时间限制:C/C++ 1秒,其他语言2秒

空间限制:C/C++ 262144K,其他语言524288K

64bit IO Format: %lld

题目描述

IG won the S championship and many people are excited, ii and gg are no exception. After watching the game, the two of them also want to play a game.

There is now an infinite chessboard with only one piece. Initially the pieces are placed at the (x, y) position (the board coordinates are counted from 0). They took turns to move the pieces. ii moves first.

There are three ways to move

1. Move the piece to the left by one space (from (x, y) to (x-1, y)).

2. Move the piece down one space (from (x, y) to (x, y-1)).

3. Move the piece to the lower left by one space (from (x, y) to (x-1, y-1)).

It should be noted that the pieces cannot be removed from the board.

The first  person who can not operate is judged negative (in other words, the first person who moves the piece to (0,0) wins).

Now give the initial coordinates x, y of the piece. Under the premise that both take the optimal strategy, please output the name of the winner (ii or gg).

输入描述:

The input contains only one line. Enter two integers x  y to represent the initial coordinates of the piece. (0<=x, y<=1000)。

输出描述:

the winner's name (ii or gg)。

示例1

输入

复制

1 1

输出

复制

ii

示例2

输入

复制

124 654

输出

复制

gg

思路:这个题的常规解法应该是SG函数,但是自己在纸上推一下能发现如代码所示的规律

代码:

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring> using namespace std; int main()
{
int a,b;
cin>>a>>b;
if(a%2==0&&b%2==0)
{
cout<<"gg"<<endl;
}
else
{
cout<<"ii"<<endl;
} return 0;
}

II play with GG(思维规律)的更多相关文章

  1. II play with GG

    https://ac.nowcoder.com/acm/contest/338/I 题解:首先轮到出手的时候如果在(0,0)上肯定是输的,而(0,1)(1,0)(0,2)(2,0)(1,1)肯定是赢的 ...

  2. 湖南大学第十四届ACM程序设计新生杯(重现赛)I:II play with GG(博弈论||DP)

    链接:https://ac.nowcoder.com/acm/contest/338/I 来源:牛客网 题目描述 IG won the S championship and many people a ...

  3. UVa10025 The ? 1 ? 2 ? ... ? n = k problem 数学思维+规律

    UVa10025 ? 1 ? 2 ? ... ? n = k problem The problem Given the following formula, one can set operator ...

  4. Harmonic Number (II) LightOJ - 1245 (找规律?。。。)

    题意: 求前n项的n/i  的和 只取整数部分 暴力肯定超时...然后 ...现在的人真聪明...我真蠢 觉得还是别人的题意比较清晰 比如n=100的话,i=4时n/i等于25,i=5时n/i等于20 ...

  5. CF 1064B Equations of Mathematical Magic(思维规律)

    Description Colossal! — exclaimed Hawk-nose. — A programmer! That's exactly what we are looking for. ...

  6. HDU 5881--Tea 思维规律

    感谢http://blog.csdn.net/black_miracle/article/details/52567718 题意:有一壶水, 体积在 L和 R之间, 有两个杯子, 你要把水倒到两个杯子 ...

  7. ZOJ-Little Sub and Pascal's Triangle(思维规律)

    Little Sub is about to take a math exam at school. As he is very confident, he believes there is no ...

  8. Codeforces Gym101257F:Islands II(求割点+思维)

    http://codeforces.com/gym/101257/problem/F 题意:给出一个n*m的地图,上面相同数字的代表一个国家,问对于每个国家有多少个国家在它内部(即被包围).例如第一个 ...

  9. Sequence in the Pocket【思维+规律】

    Sequence in the Pocket 题目链接(点击) DreamGrid has just found an integer sequence  in his right pocket. A ...

随机推荐

  1. python的上下文管理器

    直接上代码: f = open('123.txt','w') try: f.write('hello world') except Exception: pass finally: f.close() ...

  2. Cocos2d-x中判断点击是否在触摸屏区域

    新建2dx工程. 在HelloWorld头文件加入以下语句: virtual void registerWithTouchDispatcher();//注册触屏事件 覆写register方法 virt ...

  3. elasticsearch ——id字段说明,内部是_uid

    _id field Each document indexed is associated with a _type (see the section called “Mapping Typesedi ...

  4. mysql密码过期的修改方法(your password has expired)

    今天打开SQLyog提示密码过期:Your password has expired 解决方法:    1.  启动MySQL服务 2.  启动MySQL后台 3.  执行以下命令 step 1: S ...

  5. Stop logging "internal dummy connection" in Apache

    Apache 2.x keeps child processes alive by creating internal connections which appear in the log file ...

  6. PowerDesigner根据SQL文件生成PDM数据字典

    当PowerDesigner不能直接连接到数据库的时候,可以用到下面这个方法生成数据字典(直接连接数据库生成数据字典在上次随笔中有介绍). 具体操作步骤截图: ↓↓↓这里选择的sql文件是从数据库导出 ...

  7. Hive操作笔记

    hive库清表,删除数据 insert overwrite table lorry.bigdata select * from lorry.bigdata where 1=0 hive的simple模 ...

  8. 'ascii' codec can't decode byte 0xe6 in position 0: ordinal not in range(128)

    No valid host was found. There are not enough hosts available 'ascii' codec can't decode byte 0xe6 i ...

  9. 希尔排序(java)

    希尔排序是对直接插入排序的一种优化,基本思想是把待排序的数据元素分成若干个小组,对同一小组内的数据元素用直接插入法排序:小组的个数逐次缩小:当完成了所有数据元素都在一个组内的排序后排序过程结束.希尔排 ...

  10. “找女神要QQ号码”——跟风篇java新手版(求指点)

    吃完粽子后闲来无事,于是准备在园子里面看看.突然看到了一个“找女神要QQ号码”的文章,顿时精力充沛了~~^_^. 该文章楼主说明此算法来自于<啊哈!算法>,图文并茂,非常不错.<啊哈 ...