一、题目

"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 (≤10​4​​), 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?

二、题目大意

给出N个学生的排名,输出他们每个人的奖品,排名是质数的奖品小黄人,每个人都有巧克力。若查询人不在排名里,则输出“Are you kidding?”,查询过的输出“Checked”

三、考点

set、数组

四、注意

1、使用数组保存每个人的排名状态,注意没有出现的人;

2、依据排名状态输出查询结果。

五、代码

#include<iostream>
#include<algorithm>
#include<math.h>
#include<set>
using namespace std;
int a[10001] = {0};
bool isPrime(int n) {if (n == 2 || n == 3)return true;for (int i = 2; i <= sqrt(n); ++i)if (n%i == 0)return false;return true;
}
int main() {//readint n;cin >> n;//buildfor(int i=1;i<=n;++i) {int m;cin >> m;if (i == 1)a[m] = 1;else if (isPrime(i))a[m] = 2;elsea[m] = 3;}//solveset<int> sset;cin >> n;while (n--) {int m;cin >> m;//cout << m << ": ";printf("%04d: ", m);//not findif (a[m] == 0) {cout << "Are you kidding?" << endl;continue;}//Un_Checkedif (sset.find(m) == sset.end()) {sset.insert(m);switch (a[m]) {case 1:cout << "Mystery Award" << endl;break;case 2:cout << "Minion" << endl;break;case 3:cout << "Chocolate" << endl;break;}    }//Checkedelsecout << "Checked" << endl;}system("pause");return 0;
}

【笨方法学PAT】1116 Come on! Let's C (20 分)相关推荐

  1. 笨方法学python6-10

    习题6:字符串和文本 作者提示: 1.尝试破坏代码 然后自己去修复. 代码 type_of_people = 10 #变量赋予 x=f"There are {type_of_people} ...

  2. 笨方法学python习题4

    变量和命名 #笨方法学python_习题4#定义变量 cars = 100 space_in_a_car = 4.0 drivers = 30 passengers = 90#计算 cars_not_ ...

  3. 笔记 | 笨方法学Python

    整理 | 阿司匹林 出品 | 人工智能头条(公众号ID:AI_Thinker) Python 有多好应该不用多说了,毕竟它是"钦定的"最接近 AI 的语言.(当然,PHP 才是最好 ...

  4. 《 笨方法学 Python 》_ 目录

    < 笨方法学 Python >(第 3 版)书中代码是 Python 2 版本,本着学习 Python 3 的目的,用 Python 3 完成本书的习题,代码也已上传到 Github. 作 ...

  5. 笨方法学Python(二)

    笨方法学Python,习题16 - 21 版本:3.8.0 编辑器:Visual Studio Code 习题16到21讲的是文件的读写和函数的基础,可以通过一个实例来同时练习他们.在下列情景中,我将 ...

  6. 笨方法学python 习题37

    还是在笨方法学python中... 本节的习题是看一下作者列出的python中的各种运算符,尝试来理解这些符号. 在这里,我只列出了一些自己不会的,通过查百度得到得答案,这里来列举一下. (另外有不怎 ...

  7. 笨方法学python 15章疑问

    ** 笨方法学python 15章疑问 在15张中教我们读取文件,但是当我测试能否打开我之前写的py格式的文本时出现了这一幕 文件打开后然后又出现了 File "15.py", l ...

  8. PAT乙级 1003 我要通过! (20分)

    PAT乙级练习总结 PAT乙级 1003 我要通过! (20分) 第二版有注释,希望我的思路可以帮助你. 文章目录 PAT乙级练习总结 一.1003题目 二.第一版只过了三个点 三.第二版 1003 ...

  9. 笨方法学python3-笨办法学python3 pdf下载|

    笨办法学python pdf电子版可以帮助想学习python编程的同学入门,你可以从上面学习如何快捷编写python代码,以及运行过程,还有非常多的习题讲解,需要的朋友可以来当易网下载使用. 笨办法学 ...

最新文章

  1. paloalto防火墙版本升级
  2. leetcode84 巨魔卡柱子
  3. struts2 实现多文件限制上传
  4. 如何把关联性的告警智能添加到 Nagios 上?(2)
  5. 04_ClickHouse表引擎概述、MergeTree系列引擎、Log系列引擎、集成引擎、特定功能的引擎(学习笔记)
  6. 如何使Putty会话颜色更美观
  7. python socks5 代理服务
  8. Android 组件系列-----Activity初步
  9. 移动应用可以通过微信沟通接口连接公众号 微信涨粉多了一个新通道
  10. linux删除jpeg动态库,linux如何不用的删除动态库
  11. 10-fold Cross Validation
  12. Groovy获取json和xml数据
  13. Android中service的生命周期
  14. 野指针   悬垂指针   迷途指针
  15. flash builder激活
  16. 单片机定时器TMOD与TCON详解!
  17. Java流程控制语句-顺序结构
  18. Spring publishevent事件处理
  19. 关于中部城市人才外流问题的思考
  20. 使用Excel和Matlab批量修改图片名称

热门文章

  1. java贪吃蛇代码idea_IntelliJ idea使用笔记 - 贪吃蛇学院-专业IT技术平台
  2. 损坏的映像 错误0xc0000020
  3. select 检索数据
  4. 游戏运营相关名词及解释
  5. idc机房建设费用_数据中心机房收费标准
  6. 【计网】(三)超网、路由、NAT协议
  7. 解决 SQLite报错:OperationalError: row value misused
  8. Android6.0动态权限申请及RxPermissions权限库使用
  9. ECharts地图进去直接显示数字和颜色问题
  10. 使用Notepad++实现文本编辑的豆沙绿背景颜色,护眼