UESTC_Little Deer and Blue Cat CDOJ 1025

时间:2021-07-14 12:10:03

In DOTA, there are two Intellegence heroes. One is Enchantress, who is usually called Little Deer by Chinese players. The other is Storm Spirit, who is usually called Blue Cat by Chinese players.

Well, in UESTC-ACM Team, there are two Intellegent team members. One is acerlawson, who is usually called God Li by others. The other is qzy, who is usually called Master Qiu by others.

One day, qzy and acerlawson are arguing with each other about who is the best DOTA player in the team, so they want to play a game. The game is played in DOTA. However, the rule of the game is quite different from DOTA.

In the game, acerlawson plays Little Deer, and qzy plays Blue Cat. They plays the game in turn, and acerlawson goes first. At frist, Little Deer has A HP, and Blue Cat has B HP. In each hero's turn, the hero can choose an integer P and attack the enemy. The enemy will lose P HP. Here P can be 1 or any prime number not greater than the enemy's HP. The one whose HP become 0 first will lose the game.

As they are both intellegent, they will make the best choice to win this game. In another word, they will try to kill the other as early as possible.

Your task is really simple: Given A and B, find out who will win this game.

Input

The first line is an integer T(1≤T≤1000), the number of test cases.

Then T lines follows.

Each line contains two integers A and B(1≤A,B≤108).

Output

For each test case, print God Li if acerlawson will win the game. Otherwise print Master Qiu.

Sample input and output

Sample Input Sample Output
3
2 4
4 4
99999989 4
Master Qiu
God Li
Master Qiu

解题报告:

注意到哥德巴赫猜想,任意大于2的偶数必能写成2个素数之和.

so,偶数的情况我们就解决了,那么奇数了?,很显然我们可以得出一个结论:

任意奇数HP的最多三下就GG(扣一点血转换成偶数)

除去素数,那么奇数二下就死如何判断呢?

...do not ask me,i use dp prove that if (x-2) is a prime,he will die in twice

 #include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std; bool IsPrime(int x)
{
if (x <= )
return true;
int k = sqrt(x) + ;
for(int i = ; i <= k ; ++ i)
if ( !(x % i))
return false;
return true;
} int main(int argc,char *argv[])
{
int Case;
scanf("%d",&Case);
while(Case--)
{
int hp1,hp2;
int t1,t2;
scanf("%d%d",&hp1,&hp2);
if ( hp1 % == )
{
if (hp1 == )
t1 = ;
else
t1 = ;
}
else
{
if (IsPrime(hp1))
t1 = ;
else
{
if (IsPrime(hp1-))
t1 = ;
else
t1 = ;
}
} if ( hp2 % == )
{
if (hp2 == )
t2 = ;
else
t2 = ;
}
else
{
if (IsPrime(hp2))
t2 = ;
else
{
if (IsPrime(hp2-))
t2 = ;
else
t2 = ;
}
}
if (t1 >= t2)
printf("God Li\n");
else
printf("Master Qiu\n");
}
return ;
}