Source:

PAT A1116 Come on! Let's C (20 分)

Description:

"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?

Keys:

  • 素数(Prime)

Attention:

  • 对于较大规模的数据,采用打表的方法可以大大的优化时间,平时应该养成习惯已备不时之需;

Code:

 /*
Data: 2019-06-11 20:19:43
Problem: PAT_A1116#Come on! Let's C
AC: 15:40 题目大意:
按排名给出N名同学的ID,
第一名,Mystery Award
素数名次,Minion
其他名次,Chocolate
询问过了,Checked
占便宜者,Are you kidding?
*/ #include<cstdio>
#include<string>
#include<vector>
#include<iostream>
using namespace std;
const int M=1e5;
int isPrime[M],n,name;
string id[M];
vector<int> prime; void Euler()
{
fill(isPrime,isPrime+n+,);
isPrime[]=;isPrime[]=;
for(int i=; i<=n; i++){
if(isPrime[i])
prime.push_back(i);
for(int j=; j<prime.size(); j++){
if(i*prime[j]>n)
break;
isPrime[i*prime[j]]=;
if(i%prime[j]==)
break;
}
}
} int main()
{
#ifdef ONLINE_JUDGE
#else
freopen("Test.txt", "r", stdin);
#endif scanf("%d", &n);
Euler();
for(int i=; i<=n; i++)
{
scanf("%d", &name);
if(i == )
id[name] = "Mystery Award";
else if(isPrime[i])
id[name] = "Minion";
else
id[name] = "Chocolate";
}
scanf("%d", &n);
for(int i=; i<n; i++)
{
scanf("%d", &name);
printf("%04d: ", name);
if(id[name].size() != ){
cout << id[name] << endl;
id[name] = "Checked";
}
else
cout << "Are you kidding?" << endl;
} return ;
}

PAT_A1116#Come on! Let's C的更多相关文章

随机推荐

  1. P - How many

    Give you n ( n < 10000) necklaces ,the length of necklace will not large than 100,tell me How man ...

  2. js 实现栈的结构

    js实现一个栈的数据结构 首先了解一下什么是栈,栈是一个后进先出的一种数据结构,执行起来效率比较高. 对于栈主要包括一些方法,弹出栈pop(),弹出栈顶元素,并删除该元素:压入栈push(),向栈中压 ...

  3. 【从0開始Tornado建站】发表文章和评论

            先上个效果图: 这是每一个用户的主页.由于是基本功能.所以用户头像.爱好等信息都还没有,在下一阶段加上.右側"发表新文章"按钮点击后进入发表文章的页面: 之前尝试过 ...

  4. vim快速操作

    简明 VIM 练级攻略 vim的学习曲线相当的大(参看各种文本编辑器的学习曲线),所以,如果你一开始看到的是一大堆VIM的命令分类,你一定会对这个编辑器失去兴趣的.下面的文章翻译自<Learn ...

  5. Android 聊天表情输入、表情翻页带效果、下拉刷新聊天记录

    经过一个星期的折腾,最终做完了这个Android 聊天表情输入.表情翻页带效果.下拉刷新聊天记录.这仅仅是一个单独聊天表情的输入,以及聊天的效果实现.由于我没有写server,所以没有两方聊天的效果. ...

  6. 【特征匹配】SIFT原理之KD树+BBF算法解析

    转载请注明出处:http://blog.csdn.net/luoshixian099/article/details/47606159 继上一篇中已经介绍了SIFT原理与C源代码剖析,最后得到了一系列 ...

  7. uva1084

    状压dp+凸包 并没有看出来凸包的性质 首先答案一定在凸包上,然后每个凸包的角加起来是一个圆,那么就相当于凸包周长加一个圆了.然后预处理,再状压dp计算即可. #include<bits/std ...

  8. Python 41 完整查询语句 和 一堆关键字

    一:完整查询语句 1.拷贝表 *** create table copy_table select *from customer ; 拷贝结构 与数据 create table copy_table ...

  9. WebApi里面路由机制的原理以及路由匹配的过程

    1.WebApi服务启动之后,会执行全局配置文件Global.asax.cs的 protected void Application_Start(){GlobalConfiguration.Confi ...

  10. Bootstrap3.0的栅格布局系统实现原理

    这个标题取的有点奇怪,怪我翻译的有问题吧.英文学平有限,有道词典和google翻译齐上阵是必须的.还好翻译的不是小说,对于技术文章,还是能勉强翻过来的. 本文主要讲解了Bootstrap3.0的栅格布 ...