【PAT】【Advanced Level】1116. Come on! Let's C (20)
来源:互联网 发布:东北大学软件学院宿舍 编辑:程序博客网 时间:2024/06/06 02:48
1116. Come on! Let's C (20)
"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 (<=10000), 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:61111666688881234555500016888800011111222288882222Sample Output:
8888: Minion0001: Chocolate1111: Mystery Award2222: Are you kidding?8888: Checked2222: Are you kidding?
原题链接:
https://www.patest.cn/contests/pat-a-practise/1116
思路:
map映射名次,然后取出判断,同时查询过的设特殊标记
CODE:
#include<iostream>#include<map>#include<cstring>#include<string>using namespace std;map<string,int> ma;int pri(int n){if (n==2||n==3) return 1;for (int i=2;i*i<=n;i++){if (n%i==0)return 0;}return 1;}int main(){int n;cin>>n;for (int i=1;i<=n;i++){string t;cin>>t;ma[t]=i;}int m;cin>>m;for (int i=0;i<m;i++){string q;cin>>q;cout<<q<<": ";if (ma[q]==0) {cout<<"Are you kidding?"<<endl;}else if (ma[q]==-1){cout<<"Checked"<<endl;}else{if (ma[q]==1){cout<<"Mystery Award"<<endl;}else if (pri(ma[q])){cout<<"Minion"<<endl;}else{cout<<"Chocolate"<<endl;}ma[q]=-1;}}return 0;}
- 【PAT】【Advanced Level】1116. Come on! Let's C (20)
- PAT (Advanced Level) Practise 1116Come on! Let's C (20)
- PAT (Advanced Level) Practise 1116 Come on! Let's C (20)
- PAT--1116. Come on! Let's C
- PAT 1116. Come on! Let's C
- 【PAT】1116. Come on! Let's C
- pat 1116. Come on! Let's C
- PAT(A) 1116. Come on! Let's C (20)
- PAT 甲级 1116. Come on! Let's C (20)
- 1116. Come on! Let's C (20)
- 1116. Come on! Let's C (20)
- 1116. Come on! Let's C (20)
- 1116. Come on! Let's C (20)
- 1116. Come on! Let's C (20)
- 1116. Come on! Let's C (20)
- 1116. Come on! Let's C (20)
- 1116. Come on! Let's C (20)
- 1116. Come on! Let's C (20)
- mysql 的使用
- windows10 安装homestead简单记录
- 文件流fstream和字符串流sstream的使用
- Python02_函数
- nginx配置404重定向
- 【PAT】【Advanced Level】1116. Come on! Let's C (20)
- 分治题目
- LInux下如何安装ffmpeg
- vs2008 C++创建和调用标准DLL
- ubuntu 16.04 安装mysqlclient数据库驱动
- 项目重点技术
- Python03_高级特性
- Js进阶知识(二)
- 虚拟机Debian7.7-amd64-standard安装VMware-tools