PAT 1116 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<bits/stdc++.h>
using namespace std;
typedef long long ll; bool is_prime(int x){
for(int i=;i <= sqrt(x);i++){
if(x%i == ) return false;
}
return true;
} int main(){ int n;
cin >> n;
map<string,string> mp; for(int i=;i <= n;i++){
string s;
cin >> s;
if(i==){mp[s] = "Mystery Award";}
else if(is_prime(i)){mp[s] = "Minion";}
else if(!is_prime(i)){mp[s] = "Chocolate";}
} int q;
cin >> q;
while(q--){
string s;
cin >> s;
cout << s << ": ";
if(mp[s] == "")cout << "Are you kidding?"<< endl;
else if(mp[s] == "Checked") cout << "Checked" << endl;
else if(mp[s] == "Minion"){
cout << "Minion" << endl;
mp[s] = "Checked";
}
else if(mp[s] == "Mystery Award"){
cout << "Mystery Award" << endl;
mp[s] = "Checked";
}
else if(mp[s] == "Chocolate"){
cout << "Chocolate" << endl;
mp[s] = "Checked";
} } return ;
}
白给题,map的运用。
PAT 1116 Come on! Let's C的更多相关文章
- PAT 1116 Come on! Let's C [简单]
1116 Come on! Let's C (20 分) "Let's C" is a popular and fun programming contest hosted by ...
- pat 1116 Come on! Let's C(20 分)
1116 Come on! Let's C(20 分) "Let's C" is a popular and fun programming contest hosted by t ...
- PAT 甲级 1116. Come on! Let's C (20) 【循环判断】
题目链接 https://www.patest.cn/contests/pat-a-practise/1116 思路 注意一个细节 如果没有本来 ID 的 后来又查了这个ID 不是输出 checked ...
- 【PAT甲级】1116 Come on! Let's C (20分)
题意: 输入一个正整数N(<=10000),接着依次输入N个学生的ID.输入一个正整数Q,接着询问Q次,每次输入一个学生的ID,如果这个学生的ID不出现在之前的排行榜上输出Are you kid ...
- PAT 甲级真题题解(63-120)
2019/4/3 1063 Set Similarity n个序列分别先放进集合里去重.在询问的时候,遍历A集合中每个数,判断下该数在B集合中是否存在,统计存在个数(分子),分母就是两个集合大小减去分 ...
- PAT甲级题解(慢慢刷中)
博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6102219.html特别不喜欢那些随便转载别人的原创文章又不给 ...
- PAT甲级目录
树(23) 备注 1004 Counting Leaves 1020 Tree Traversals 1043 Is It a Binary Search Tree 判断BST,BST的性质 ...
- PAT甲级 散列题_C++题解
散列 PAT (Advanced Level) Practice 散列题 目录 <算法笔记> 重点摘要 1002 A+B for Polynomials (25) 1009 Product ...
- 《转载》PAT 习题
博客出处:http://blog.csdn.net/zhoufenqin/article/details/50497791 题目出处:https://www.patest.cn/contests/pa ...
随机推荐
- t-SNE完整笔记
http://www.datakit.cn/blog/2017/02/05/t_sne_full.html t-SNE(t-distributed stochastic neighbor embedd ...
- IT题库8-死锁
一.死锁原理 死锁是指两个或两个以上的进程在执行过程中,由于竞争资源或者由于彼此通信而造成的一种阻塞的现象,若无外力作用,它们都将无法推进下去.此时称系统处于死锁状态或系统产生了死锁,这些永远在互相等 ...
- 论文笔记【三】A Deep Dive into Word Sense Disambiguation with LSTM
深入理解LSTM词义消歧 Minh Le,Marten Postma,Jacopo Urbani和Piek Vossen 阿姆斯特丹自由大学语言,文学和传播系 阿姆斯特丹自由大学计算机科学系 摘要 基 ...
- Java中==和equals方法
Java程序中测试两个变量是否相等有两种方式:1.== :2.equals()方法 当使用==来判断两个变量是否相等时,如果两个变量是基本类型变量,且都是基本数值类型(不一定要求数据类型严格相同),则 ...
- Pandas逐行读取Dateframe并转为list
for indexs in df.index: rowData = df.loc[indexs].values[0:7] rowData = rowData.tolist() #print(rowDa ...
- 有些人表面风光,背地里for循环怎么写都要百度
代码地址 https://github.com/ljshLLW/homework 题目 最大连续子数组和(最大子段和) 给定n个整数(可能为负数)组成的序列a[1],a[2],a[3],-,a[n], ...
- 【Linux】文件IO --- sync、fsync、fdatesync
在使用write函数向文件中写入数据的时候,并不是在调用了函数以后就直接把数据写入磁盘:操作系统在内核中设置了一块专门的缓冲区,数据会先被写入到内核的缓冲区中,等到缓冲区满了或者系统需要重新利用缓冲区 ...
- web.xml的学习
web.xml 文件提供有关包含 Web 应用程序的 Web 组件的配置和部署信息. Java Servlet 规范根据 XML 模式文档来定义 web.xml 部署描述符文件.为了获取向后兼容性,W ...
- centos设置网卡开机自启动
1.进入目录/etc/sysconfig/network-scripts/2.修改ifcfg-enxxxxxxxx 文件 (即你的网卡标识命名的配置文件)3. 将ONBOOT=no改成yes4. ...
- Bootstrap常用单词组
布局容器 .container 固定宽度 .container-fluid 全屏 .row 行 .col-lg- 大屏幕 .col-md- 中屏幕 变量 @grid-columns: 12 列数 @g ...