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 ...
随机推荐
- 移植strace调试工具到arm平台
strace工具是一个非常强大的工具,是调试程序的好工具.要移植到arm平台,就需要使用交叉编译工具编译生成静态链接的可执行文件.具体步骤如下:1.下载 strace-4.5.16 移植str ...
- 【HDU1879】继续畅通工程(MST基础题)
真心大水题...不多说. #include <iostream> #include <cstring> #include <cstdlib> #include &l ...
- Python 协程(gevent)
协程,又叫微线程,协程是一种用户态的轻量级线程. 协程拥有自己的寄存器上下文和栈.协程调度切换时,将寄存器上下文和栈保存到其他地方,在切回来的时候,恢复先前保存的寄存器上下文和栈.因此: 协程能保留上 ...
- 基础总结篇之九:Intent应用详解
看似尋常最奇崛,成如容易卻艱辛.北宋.王安石 看似普通的事情其实最不同寻常,并不是简简单单就可以做好的:成功看起来似乎很容易,而成功的过程却充满着艰辛. 对于我们认为很普通的事情,不屑一顾,就永远不会 ...
- Deep Compression Compressing Deep Neural Networks With Pruning, Trained QuantizationAnd Huffman Coding
转载请注明出处: http://www.cnblogs.com/sysuzyq/p/6200613.html by 少侠阿朱
- Hacker(十一)----黑客常用入侵方法
Internet中,为了防止黑客入侵自己的电脑,就必须了解黑客入侵目标计算机的常用方法.黑客常用的入侵方法有数据驱动攻击.系统文件非法利用.伪造信息攻击.远端操纵等. 一.数据驱动攻击 数据驱动攻击是 ...
- 注册界面的优化之ActionBar组件的应用之(一)ActionBar组件的布局实现
开发步骤: 在res下menu文件夹中创建一个actionbar_menu_register.xml菜单资源文件 在资源文件中添加标签设置一个或多个ActionBar功能选项 //action ...
- Android-现场保护
现场保护 当一个活动进入到了停止的状态,是有可能被系统回收的,我们都学过Activity的生命周期 当活动处于onPause() ,onStop() ,onDestroy() 三种状态时程序可能会被A ...
- asp.net缓存(一)
ASP.NET页面输出缓存(OutputCache) 页面输出缓存是最为简单的缓存机制,该机制将整个ASP.NET页面内容保存在服务器内存中.当用户请求该页面时,系统从内存中输出相关数据,直到缓存数据 ...
- ORA-00937:不是单组分组函数_Oracle
Demo: SELECT USER_ID, USER_NAME, USER_SEX, MAX(USER_AGE), SUM(USER_MONEY) AS USER_MONEY USER_TEL, US ...