PAT_A1116#Come on! Let's C
Source:
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: awardwhere the award isMystery Award, orMinion, orChocolate. If the ID is not in the ranklist, printAre you kidding?instead. If the ID has been checked before, printID: 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的更多相关文章
随机推荐
- Javascript:使用jQuery提交Form表单
DEMO说明一切: // this is the id of the form $("#idForm").submit(function() { var url = "p ...
- VMware Workstation 集群仲裁磁盘和数据共享磁盘的创建
近期项目须要对SQL Server建立集群服务,多个SQL Server数据库建立集群服务,对外提供唯一的URL訪问地址.当主节点断电.断网后,通过心跳线将消息传递到备用节点.备用节点在3秒内接管数据 ...
- jsp页面中使用javascript获取后台放在request或session中的值
在JSP页面中.常常使用javascript,可是要出javascript获取存储在request,session, application中的值.例如以下是获取request中的值: 如果后台中有: ...
- SpringMVC中的 --- 异常处理
系统异常处理器SimpleMappingExceptionResolver 处理器方法执行过程中,可能会发生异常,不想看到错误黄页,想看到一个友好的错误提示页. 自定义异常处理器 使用异常处理注解
- POJ - 3281 Dining(拆点+最大网络流)
Dining Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 18230 Accepted: 8132 Descripti ...
- hdu 1429(BFS+状态压缩)
胜利大逃亡(续) Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Su ...
- P3387 【模板】缩点 tarjan
虽说是模板题,但是竟然中间有dp的部分...先tarjan缩点,重新建图.然后记忆化搜索,搜索dag中的最小环. 题干: 题目背景 缩点+DP 题目描述 给定一个n个点m条边有向图,每个点有一个权值, ...
- Win7系统专栏
1.去掉Win7快捷方式小箭头的方法如下: 使用普通方法会使系统出现异常,比如开始菜单程序无法删除.收藏夹无法展开等,网上流传使用透明图标的方法会在快捷方式上留下一块黑痣,下面的方法是小君研究出来的, ...
- javascript之模块加载方案
前言 主要学习一下四种模块加载规范: AMD CMD CommonJS ES6 模块 历史 前端模块化开发那点历史 require.js requirejs 为全局添加了 define 函数,你只要按 ...
- 利用poi,jxl将Excel数据导入数据库
需求:‘需要将本地的Excel中的数据经过验证之后导入数据库,在导入数据库之前在页面上展示出来 思路:将Excel导入存到session里面 去判断有没有不合法数据 如果有阻止提交 工具类: imp ...