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分解. 输入规格: ...
随机推荐
- leetcood学习笔记-172-阶乘后的0
题目描述: 方法:不断除以 5, 是因为每间隔 5 个数有一个数可以被 5 整除, 然后在这些可被 5 整除的数中, 每间隔 5 个数又有一个可以被 25 整除, 故要再除一次, ... 直到结果为 ...
- 【历年真题】斐波那契数列logn做法
描述 [题解] 用矩阵乘法加速递推 [0 1] [1 1] [f[n-1]] [f[n-2]] = [f[n-1]] [f[n]] 求A矩阵的n-2次幂然后再乘B矩阵. 结果矩阵中的第二行第一列就是f ...
- java之短路与&&和短路或||
短路的意思就是惰性计算,符号右边的就不进行计算了. ||和&&就是这样,
- 让BB-Black通过usb0上网
Frm: http://blog.csdn.net/jamselaot/article/details/17080011 既然我们已经用usb0作为主机和BB-Black之间的网络通道了,再进一步,就 ...
- ncurses库的介绍与安装
Frm: http://blog.csdn.net/Mary_Jane/article/details/50769631 介绍 ncurses(new curses)是一套编程库,它提供了一系列的函数 ...
- Codeforces 1163A - Eating Soup
题目链接:http://codeforces.com/problemset/problem/1163/A 题意:n 只猫围成一圈,离开 m 只,最多剩下几组猫. 思路:当 n == m 即猫都离开时 ...
- 拾遗:Unix 守护进程编写规范
//标准库自带函数,通常以 daemon(0, 0) 方式调用 int daemon(int nochdir, int noclose) Linux: #include <unistd.h> ...
- 基于三角形与位置指纹识别算法的WiFi定位比较
文章来着:https://wenku.baidu.com/view/55d1f4146edb6f1aff001fec.html
- Ulimit 文件配置
cat /etc/security/limits.confsudo vim /etc/security/limits.conf * hard nofile 999999 * soft nofile 9 ...
- 创建第一个spirngmvc小项目
题外: 设置目录为源代码目录 1.进入:file->project structure->modules->soures 进入这个里面,选择相应的文件夹.例如src/java里的ja ...