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 |
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 ;
}
UESTC_Little Deer and Blue Cat CDOJ 1025的更多相关文章
- [.net 面向对象程序设计进阶] (2) 正则表达式 (一) 快速入门
[.net 面向对象程序设计进阶] (2) 正则表达式 (一) 快速入门 1. 什么是正则表达式? 1.1 正则表达式概念 正则表达式,又称正则表示法,英文名:Regular Expression(简 ...
- VennDiagram 画文氏图/维恩图/Venn
install.packages("VennDiagram")library(VennDiagram) A = 1:150B = c(121:170,300:320)C = c(2 ...
- Linux下为何都是文件的理解
所谓“文件”,就是在我们的电脑中,以实现某种功能.或某个软件的部分功能为目的而定义的一个单位. Linux都是以文件的形式存在,当我们访问某个文件(Linux中的文件有目录,连接,普通文本),由于Li ...
- Java-UrlRewrite中文api文档
安装 1. 下载jar包, 并加入到WEB-INF/lib下 2. 在WEB-INF/web.xml中增加下面的配置 <filter> <filter-name>UrlRewr ...
- JS中创建自定义对象的方法
1.直接给对象扩充属性和方法: 2.对象字面量: 3.工厂方式: 4.构造函数方式: 5.原型方式: 6.混合方式. <script> // 1.直接给对象扩充属性和方法; var cat ...
- python学习笔记(6)
第6章 组合数据类型 组合类型的三种表达形式:集合.序列.字典 集合类型及操作 定义:集合是多个元素的无序组合 集合类型与数学中的集合概念一致 集合元素之间无序,每个元素唯一,不存在相同元素 集合元素 ...
- php7 教程
标量类型声明 1. 分为强制模式和严格模式 2. 这些类型的函数参数可以执行声明 int, float, bool, string, interfaces, array, callable 例如: f ...
- 70个注意的Python小Notes
Python读书笔记:70个注意的小Notes 作者:白宁超 2018年7月9日10:58:18 摘要:在阅读python相关书籍中,对其进行简单的笔记纪要.旨在注意一些细节问题,在今后项目中灵活运用 ...
- 用R画韦恩图
#导入R包 library(grid)library(futile.logger)library(VennDiagram) #建立测试数据集 A = 1:150B = c(121:170,300:32 ...
随机推荐
- SQLite-CONSTRAINTS(约束)
SQLite – CONSTRAINTS(约束) 约束是数据列在表上执行的规则.这些是用来限制的数据类型可以进入一个表.这样可以确保数据的准确性和可靠性在数据库中. 级或表级约束可以列.列级约束是仅适 ...
- poj 3684 Physics Experiment(数学,物理)
Description Simon ), the first ball is released and falls down due to the gravity. After that, the b ...
- eq,neq,gt,lt等表达式缩写
eq 等于neq 不等于gt 大于egt 大于等于lt 小于elt 小于等于like LIKEbetween BETWEENnotnull IS NUT NULLnull IS NULL
- 平时的笔记02:处理fnmatch模块
# Copyright 2006 Joe Wreschnig## This program is free software; you can redistribute it and/or modif ...
- RelativeLayout经常使用属性介绍
以下介绍一下RelativeLayout用到的一些重要的属性: 第一类:属性值为true或false android:layout_centerHrizontal ...
- UDK——入门开发流程
1.入门级參考UnrealScript代码 UnrealScript模仿JAVA,可是又有巨大的不同,主要是它本身具有完好的结构,貌似UDK把一切都安排好了,就像在盖楼一样.面对一幢已经完工的设计静止 ...
- Hacker(十)----常用入侵工具
黑客若想攻击目标计算机,仅靠DOS命令是无法完成的,还需要一些功能强大的入侵工具,如端口扫描工具.网络嗅探工具.木马制作工具及远程控制工具等. 一.端口扫描工具 端口扫描工具有扫描端口的功能,所谓端口 ...
- [j2ee][IDEA properties中文乱码解决]
http://my.oschina.net/pengzai/blog/133908 在project settings - File Encoding,在标红的选项上打上勾,确定即可
- GridView控件中插入自定义删除按钮并弹出确认框
GridView控件中插入自定义删除按钮,要实现这个功能其实有多种方法,这里先记下我使用的方法,以后再添加其他方法. 一.实现步骤 1.在GridView中添加模板列(TemplateField). ...
- U盘制作Linux系统盘
一.首先需要有一个U盘,最好能是8G及以上的 二.下载Linux的镜像文件(我这边安装的是red hat6.3) 下载路径:http://pan.baidu.com/s/1jIGYCKI 三.下载制作 ...