Michael_Bryant最喜欢的G(al)G(ame)

那些悲伤,那些寂寞,那些几乎让自己放弃生活的希望的痛苦的回忆,绝对绝对不要将它们忘记。

Michael_Bryant最喜欢的番剧

抱歉⋯我已经绝对不可能再获得幸福了,因为⋯我发现⋯ 其实我⋯ 早就已经被幸福包围了

Michael_Bryant正在看的番剧

死亡一点也不温柔,只有无尽的黑暗和孤独。 就算联系得再紧密,人也是孤独的。

HDU 3595:GG and MM

题目链接

传送门

Problem Description

GG and MM like playing a game since they are children. At the beginning of game, there are two piles of stones. MM chooses a pile of stones first, which has x stones, and then she can choose a positive number k and remove k * x stones out from the other pile of stones, which has y stones (I think all of you know that y>=k*x - -!). Then it comes the turn of GG, followed the rules above-mentioned as well. When someone can't remove any stone, then he/she loses the game, and this game is finished.
Many years later, GG and MM find this game is too simple, so they decided to play N games at one time for fun. MM plays first, as the same, and the one on his/her turn must play every unfinished game. Rules to remove are as same as above, and if someone cannot remove any stone (i.e., loses the last ending game), then he/she loses. Of course we can assume GG and MM are clever enough, and GG will not lose intentionally, O(∩_∩)O~

Input

The input file contains multiply test cases (no more than 100).
The first line of each test case is an integer N, N<=1000, which represents there are N games, then N lines following, each line has two numbers: p and q, standing for the number of the two piles of stones of each game, p, q<=1000(it seems that they are so leisure = =!), which represent the numbers of two piles of stones of every game.
The input will end with EOF.

Output

For each test case, output the name of the winner.

Sample Input

3
1 1
1 1
1 1
1
3 2

Sample Output

MM
GG

题解

直接裸的Every-SG
这题策略非常简单 只要当前两堆石子中多的是少的两倍以上 先手就可以控制先手必胜
至于不满足两倍以上的嘛 就省下一倍的了直接做就行了
判断step值奇偶性
结束

代码

One Comment

Add a Comment

电子邮件地址不会被公开。 必填项已用*标注

隐藏