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 ...
随机推荐
- back_insert_iterator和iterator用起来不一样。
先看代码: #include<iostream> #include<vector> #include<algorithm> #include<iterator ...
- 【剑指offer】面试题28:字符串的排列
题目: 输入一个字符串,按字典序打印出该字符串中字符的所有排列.例如输入字符串abc,则打印出由字符a,b,c所能排列出来的所有字符串abc,acb,bac,bca,cab和cba. 输入描述:输入一 ...
- 飘逸的python - 性能调优利器profile及其意义
VIM 的作者Bram Moolenaar在一篇叫高效文本编辑器的7个习惯的ppt中有这么一段话. Three basic steps 1. Detect inefficiency 2. ...
- poj 3320 Jessica's Reading Problem(尺取法)
Description Jessica's a very lovely girl wooed by lots of boys. Recently she has a problem. The fina ...
- hdu 5656 CA Loves GCD(dp)
题目的意思就是: n个数,求n个数所有子集的最大公约数之和. 第一种方法: 枚举子集,求每一种子集的gcd之和,n=1000,复杂度O(2^n). 谁去用? 所以只能优化! 题目中有很重要的一句话! ...
- Unity PlayerPrefs类进行扩展(整个对象进行保存)
盘子脸在制作单机游戏的时候,先以为没有好多数据需要保存本地. 就没有使用json等格式自己进行保存. 使用PlayerPrefs类,但是后面字段越来越多的时候. PlayerPrefs保存就发现要手动 ...
- pat 1049 Counting Ones
要统计1到N之间‘1’的个数,如数11包含2个1.所以当N=12时,答案为5. 思想: 找规律,假设ans[N]表示1到N的‘1’的个数,则有a[100]=(a[10]-1)*9+10+a[10]-1 ...
- chroot 与 jail
所谓“监牢”就是指通过chroot机制来更改某个进程所能看到的根文件夹,即将某进程限制在指定文件夹中,保证该进程仅仅能对该文件夹及其子文件夹的文件有所动作,从而保证整个server的安全. 创建chr ...
- Rhythmbox乱码的解决的方法
近期尝试 Listen 和 Banshee 才发现,Rhythmbox 上出现的 mp3乱码问题依然,并且更加严重,想要彻底弄清和解决必须搞清两点,第一, mp3 标签类型和编码,第二,各种播放器对 ...
- MFC读写配置文件
void CFileTextDoc::OnIniread() { // TODO: Add your command handler code here CString strStudName; ...