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(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

 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 }
时间: 2024-08-11 07:38:32

UESTC_Little Deer and Blue Cat CDOJ 1025的相关文章

常用的操作正则表达式的方法+正则表达式基本元字符使用实例

常用的操作正则表达式的方法: 下面学习一下位于System.Text.RegularExpressions下的Regex类的一些静态方法和委托(只要有一段匹配就会返回true) 1,静态方法IsMatch (返回值是一个布尔类型,用于判断指定的字符串是否与正则表达式字符串匹配,它有三个重载方法) bool IsMatch(string input, string pattern); 参数: input: 要搜索匹配项的字符串. pattern: 要匹配的正则表达式模式. 返回结果: 如果正则表达

VennDiagram 画文氏图/维恩图/Venn

install.packages("VennDiagram")library(VennDiagram) A = 1:150B = c(121:170,300:320)C = c(20:40,141:200)Length_A<-length(A)Length_B<-length(B)Length_C<-length(C)Length_AB<-length(intersect(A,B))Length_BC<-length(intersect(B,C))Leng

Linux下为何都是文件的理解

所谓“文件”,就是在我们的电脑中,以实现某种功能.或某个软件的部分功能为目的而定义的一个单位. Linux都是以文件的形式存在,当我们访问某个文件(Linux中的文件有目录,连接,普通文本),由于Linux的文件的类型 而区分:如连接文件等,那使用这个文件时,那么就是调用了某个命令: 如普通文本文件时,那么当使用这个文件时,那就是访问该文件的内容 由于文件的类型的不同,从而区别于window系统下的应用:如播放器,EditPlus,浏览器,文件夹等,这些在Linux中都有 对于的不同类型的文件!

linux系统移植和根文件系统制作

1.1 Linux内核基础知识 在动手进行Linux内核移植之前,非常有必要对Linux内核进行一定的了解,下面从Linux内核的版本和分类说起. 1.1.1  Linux版本 Linux内核的版本号可以从源代码的顶层目录下的Makefile中看到,比如2.6.29.1内核的Makefile中: VERSION = 2 PATCHLEVEL = 6 SUBLEVEL = 29 EXTRAVERSION = .1 其中的“VERSION”和“PATCHLEVEL”组成主版本号,比如2.4.2.5.

js中的继承问题

1.继承的概念:把别人的拿过来变成自己的,但自己不受影响. 2.js中最基本的继承就是原型继承. 3.原型继承:通过修改子级构造函数的prototype指向父级构造函数的实例对象. function Animal(name){ this.name=name; this.favor=['eating','sleeping']; } Cat.prototype=new Animal('Kitty'); function Cat(color){ this.color=color; } var cat=

Java-UrlRewrite中文api文档

安装 1. 下载jar包, 并加入到WEB-INF/lib下 2. 在WEB-INF/web.xml中增加下面的配置 <filter> <filter-name>UrlRewriteFilter</filter-name> <filter-class> org.tuckey.web.filters.urlrewrite.UrlRewriteFilter </filter-class> </filter> <filter-mapp

[.net 面向对象程序设计进阶] (2) 正则表达式(一)

[.net 面向对象程序设计进阶] (2) 正则表达式(一) 1.什么是正则表达式? 1.1正则表达式概念 正则表达式,又称正则表示法,英文名:Regular Expression(简写为regex.regexp或RE),是计算机科学的一个重要概念.他是用一种数学算法来解决计算机程序中的文本检索.区配等问题. 1.2正则表达式语言支持  正则表达式其实与语言无关,在很多语言中都提供了支持 ,包括最常用的脚本语言Javascript.当然C#语言也毫不例外的提供了很好的支持.     正则表达式语

Shell中eval的用法示例

功能说明:告知shell取出eval的参数,重新运算求出参数的内容. 语 法:eval [参数]补充说明:eval可读取一连串的参数,然后再依参数本身的特性来执行. 参 数:参数不限数目,彼此之间用分号分开.1.执行命令行之前扫描它两次,再次运算求出参数的内容. 复制代码 代码如下: [[email protected] blue]# a="ls |more" [[email protected] blue]# $a                                   

WINDOWS+VS2013下生成caffe并进行cifar10分类测试

http://blog.csdn.net/naaaa/article/details/52118437 标签: windowsvs2013caffecifar10 2016-08-04 15:33 1316人阅读 评论(1) 收藏 举报  分类: caffe 版权声明:本文为博主原创文章,未经博主允许不得转载. 1.下载vs2013,安装 http://download.microsoft.com/download/0/7/5/0755898A-ED1B-4E11-BC04-6B9B7D82B1