UESTC_Little Deer and Blue Cat CDOJ 1025

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(1T1000), the number of test cases.

Then T lines follows.

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

Output

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

Sample input and output

Sample InputSample 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

 

 1 #include <iostream>
 2 #include <cstring>
 3 #include <cstdio>
 4 #include <algorithm>
 5 #include <cmath>
 6 using namespace std;
 7 
 8 bool IsPrime(int x)
 9 {
10   if (x <= 2)
11    return true;
12   int k = sqrt(x) + 1;
13   for(int i = 2 ; i <= k ; ++ i)
14    if ( !(x % i))
15     return false;
16   return true;
17 }
18 
19 int main(int argc,char *argv[])
20 {
21   int Case;
22   scanf("%d",&Case);
23   while(Case--)
24    {
25          int hp1,hp2;
26          int t1,t2;
27          scanf("%d%d",&hp1,&hp2);
28          if ( hp1 % 2 == 0)
29           {
30                 if (hp1 == 2)
31                  t1 = 1;
32                 else
33                  t1 = 2;
34        }
35       else
36        {
37              if (IsPrime(hp1))
38               t1 = 1;
39              else
40               {
41                     if (IsPrime(hp1-2))
42                      t1 = 2;
43                     else
44                      t1 = 3;
45            }
46        }
47       
48       
49       if ( hp2 % 2 == 0)
50           {
51                 if (hp2 == 2)
52                  t2 = 1;
53                 else
54                  t2 = 2;
55        }
56       else
57        {
58              if (IsPrime(hp2))
59               t2 = 1;
60              else
61               {
62                     if (IsPrime(hp2-2))
63                      t2 = 2;
64                     else
65                      t2 = 3;
66            }
67        }
68       if (t1 >= t2)
69        printf("God Li\n");
70       else
71        printf("Master Qiu\n");
72    }
73   return 0;
74 }

 

 

转载于:https://www.cnblogs.com/Xiper/p/4455101.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值