PAT甲级——A1116 Come on! Let's C
"Let's C" is a popular and fun programming contest hosted by the College of Computer Science and Technology, Zhejiang University. Since the idea of the contest is for fun, the award rules are funny as the following:
- 0、 The Champion will receive a "Mystery Award" (such as a BIG collection of students' research papers...).
- 1、 Those who ranked as a prime number will receive the best award -- the Minions (小黄人)!
- 2、 Everyone else will receive chocolates.
Given the final ranklist and a sequence of contestant ID's, you are supposed to tell the corresponding awards.
Input Specification:
Each input file contains one test case. For each case, the first line gives a positive integer N (≤), the total number of contestants. Then N lines of the ranklist follow, each in order gives a contestant's ID (a 4-digit number). After the ranklist, there is a positive integer K followed by K query ID's.
Output Specification:
For each query, print in a line ID: award where the award is Mystery Award, or Minion, or Chocolate. If the ID is not in the ranklist, print Are you kidding? instead. If the ID has been checked before, print ID: Checked.
Sample Input:
6
1111
6666
8888
1234
5555
0001
6
8888
0001
1111
2222
8888
2222
Sample Output:
8888: Minion
0001: Chocolate
1111: Mystery Award
2222: Are you kidding?
8888: Checked
2222: Are you kidding?
#include <iostream>
#include <cmath>
using namespace std;
int rankList[] = {};//存储排名
bool check[] = { false };//是否已经查询过
int n, k, id;
bool isPrime(int x)
{
if (x <= )
return x > ;
for (int i = ; i*i <= x; ++i)
if (x%i == )
return false;
return true;
}
int main()
{
cin >> n;
for (int i = ; i <= n; ++i)
{
cin >> id;
rankList[id] = i;
}
cin >> k;
while (k--)
{
cin >> id;
if (rankList[id] == )
printf("%04d: Are you kidding?\n", id);
else if (check[id] == true)
printf("%04d: Checked\n", id);
else if (rankList[id] == )
printf("%04d: Mystery Award\n", id);
else if (isPrime(rankList[id]))
printf("%04d: Minion\n", id);
else
printf("%04d: Chocolate\n", id);
check[id] = true;
}
return ;
}
PAT甲级——A1116 Come on! Let's C的更多相关文章
- PAT甲级题解(慢慢刷中)
博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6102219.html特别不喜欢那些随便转载别人的原创文章又不给 ...
- PAT甲级1131. Subway Map
PAT甲级1131. Subway Map 题意: 在大城市,地铁系统对访客总是看起来很复杂.给你一些感觉,下图显示了北京地铁的地图.现在你应该帮助人们掌握你的电脑技能!鉴于您的用户的起始位置,您的任 ...
- PAT甲级1127. ZigZagging on a Tree
PAT甲级1127. ZigZagging on a Tree 题意: 假设二叉树中的所有键都是不同的正整数.一个唯一的二叉树可以通过给定的一对后序和顺序遍历序列来确定.这是一个简单的标准程序,可以按 ...
- PAT甲级1123. Is It a Complete AVL Tree
PAT甲级1123. Is It a Complete AVL Tree 题意: 在AVL树中,任何节点的两个子树的高度最多有一个;如果在任何时候它们不同于一个,则重新平衡来恢复此属性.图1-4说明了 ...
- PAT甲级1119. Pre- and Post-order Traversals
PAT甲级1119. Pre- and Post-order Traversals 题意: 假设二叉树中的所有键都是不同的正整数.一个唯一的二进制树可以通过给定的一对后序和顺序遍历序列来确定,也可以通 ...
- PAT甲级1114. Family Property
PAT甲级1114. Family Property 题意: 这一次,你应该帮我们收集家族财产的数据.鉴于每个人的家庭成员和他/她自己的名字的房地产(房产)信息,我们需要知道每个家庭的规模,以及他们的 ...
- PAT甲级1111. Online Map
PAT甲级1111. Online Map 题意: 输入我们当前的位置和目的地,一个在线地图可以推荐几条路径.现在你的工作是向你的用户推荐两条路径:一条是最短的,另一条是最快的.确保任何请求存在路径. ...
- PAT甲级1107. Social Clusters
PAT甲级1107. Social Clusters 题意: 当在社交网络上注册时,您总是被要求指定您的爱好,以便找到一些具有相同兴趣的潜在朋友.一个"社会群体"是一群拥有一些共同 ...
- PAT甲级1103. Integer Factorization
PAT甲级1103. Integer Factorization 题意: 正整数N的K-P分解是将N写入K个正整数的P次幂的和.你应该写一个程序来找到任何正整数N,K和P的N的K-P分解. 输入规格: ...
随机推荐
- web storem破解
话不多说 直接跳地址 http://idea.lanyus.com/ 再加个附带汉化包,使用方法已经放在压缩包里面 网盘链接: https://pan.baidu.com/s/1aEA6SSbDuRg ...
- tomcat 端口被占用 项目端口号被占用怎么解决
1.Win+R 打开运行 ,输入cmd 打开命令行窗口 . 2.假设要查询端口被占用情况,在命令行下输入:netstat -aon|findstr "8883" 3.得到进程 ...
- js实现截取字符串后几位
var strs ="wdsdabcdefages" strs.substring(obj.filename.lastIndexOf("a")+1,strs.l ...
- Delphi 字符串函数 StrUtils(大全)
引用单元: StrUtils; 首部 function AnsiResemblesText(const AText, AOther: string): Boolean; $[StrUtils.pas ...
- Java——面向对象的特征二:继承性
2.1面向对象的特征二:继承性 ①引入类继承最基本的作用是:代码重用. ②语法 [修饰符列表] class 子类名 extends 父类名{ 类体; } ③子类继承父类以后,父类中声明的属性.方法,子 ...
- CRI 与 ShimV2:一种 Kubernetes 集成容器运行时的新思路
摘要: 关于 Kubernetes 接口化设计.CRI.容器运行时.shimv2.RuntimeClass 等关键技术特性的设计与实现. Kubernetes 项目目前的重点发展方向,是为开发 ...
- js判断是否为手机端访问
随着移动端越来越重要,pc和移动端网站后台系统可能是同一个,登录或者某个特定时期需要根据不同访问来源,跳转不同页面或者做不同的处理: 这时我们就需要js的 navigator 对象: 我们先了解一下n ...
- SXOI2018酱油记
Day 0: 嗯前一天刚听说要去参加省选(可能以前也说了不过没听见),作为弱省高一的蒟蒻准备去打打酱油.下午去五中试机啥也没敲晃荡一圈又回去了.今年来也就是打打酱油心情自然是很平静,真不知道明年现在我 ...
- 剑指offer——06二叉树的下一个节点
题目描述 给定一个二叉树和其中的一个结点,请找出中序遍历顺序的下一个结点并且返回.注意,树中的结点不仅包含左右子结点,同时包含指向父结点的指针. 题目的意思是,在一颗二叉树的中序遍历中,给出其中一 ...
- 活动:新春第一次送书,价值78元 X 3本
新春第一次送书活动,送出3本重量级书籍<深入分布式缓存:从原理到实践>. 作者介绍: 于君泽:蚂蚁金服高级技术专家.花名右军,IT从业超过十五年.对高并发.分布式架构.内建质量.研发管理有 ...