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分解. 输入规格: ...
随机推荐
- Linux系统升级
查看centos版本的命令:uname -r 升级版本:yum -y upgrade 重启:reboot
- H5新增的postMessage跨域解决方案Demo
Demo背景:html中使用iframe嵌入了跨域的vue项目,在html中将参数传入到跨越的vue项目中. 向跨越的子窗口中发送数据 function sendMessage(data) { // ...
- leetcood学习笔记-69-x的平方根
题目描述: 第一次提交:(会超时) class Solution: def mySqrt(self, x: int) -> int: if x==0 or x==1: return x for ...
- 【转】Git 修改已提交的commit注释
https://www.jianshu.com/p/098d85a58bf1 [重点] 通过git rebase -i HEAD~2 你想修改哪条注释 就把哪条注释前面的pick换成edit git ...
- MTT学习小记
这是个毒瘤题才有的毒瘤东西--奶一口NOI不考 拆系数FFT: 考虑做NTT时模数不是NTT模数(\(2^a*b+1\))怎么办? 很容易想到拆次数FFT. 比如说现在求\(a*b\),设\(m=\s ...
- bzoj1031题解
[解题思路] 将原串复制一份拼接到原串后作为处理串,可以对处理串的前一半后缀排序,即可得出顺序.复杂度O(Llog2L). [参考代码] 也是naive的时候写的..后缀数组居然是用桶排求的.. #p ...
- bzoj1029题解
[解题思路] 贪心,先按结束时间排序,从左到右扫描过去,如果当前建筑可以修复则入大根堆,否则,若其修复时间比堆顶小则弹出堆顶并入堆,处理完堆后则更新总时间.复杂度O(nlog2n). [参考代码] # ...
- 快速排序--Python实现
快速排序算法:1.选择一个基准数2.小于基准数的放左边,大于基准数的放右边3.利用递归的方法针对左边的数据进行快速排序,再对右边的数据进行快速排序4.递归停止的条件:数组为空或者只有一个元素 时间复杂 ...
- PostgreSQL/GREENPLUM关联更新
update a_t AA set /*AA.*/ sqlstr = 'qqq' from a_t BB where aa.id <> BB.id and aa.name = BB.nam ...
- iOS开发UIResponder简介API
#import <Foundation/Foundation.h> #import <UIKit/UIKitDefines.h> #import <UIKit/UIEve ...