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的更多相关文章
随机推荐
- oracle rac cache fusion
转载自 http://blog.csdn.net/tianlesoftware/article/details/6534239 Introduction This post is about orac ...
- Clojure:将两个list合并成一个map
假设我们有两个list,分别是: (def a [“one” “two” “three”]) (def b [1 2 3]) 我们要把它们合为一个键值对应的map,做法很简单: 1. 先将a和b合为一 ...
- HDU 3001
题目中说明每个城市至少要走一次,至多走2次,因此要用到三进制压缩,然后就是状态转移方程了. 这道题就处理三进制的地方麻烦一点.同时注意,在选择最小长度时,一定是要每一个点都经过至少一次的,即是状态的每 ...
- HDU 4529
好题.果然好题,经典了. 列一个计划,清明前做好状压DP.之后就刷剩下的MULTI. #include <iostream> #include <cstdio> #includ ...
- 【Java集合源代码剖析】Hashtable源代码剖析
转载请注明出处:http://blog.csdn.net/ns_code/article/details/36191279 Hashtable简单介绍 Hashtable相同是基于哈希表实现的,相同每 ...
- 源代码管理之Git命令的使用
目录 02.源代码管理之Git命令的使用 2.Git命令行演练-个人开发 2.1 如何学习git指令 2.2 初始化创建本地仓库 2.3 个人开发基本演练 2.4 Git的基本常识 3.Git命令行演 ...
- Ural 1353 Milliard Vasya's Function(DP)
题目地址:Ural 1353 定义dp[i][j].表示当前位数为i位时,各位数和为j的个数. 对于第i位数来说.总能够看成在前i-1位后面加上一个0~9.所以状态转移方程就非常easy出来了: dp ...
- Caused by: java.lang.UnsatisfiedLinkError: Couldn't load BaiduMapVOS_v2_1_3: findLibrary returned nu
在使用百度地图进行开发的时候.假设遇到了 Caused by: java.lang.UnsatisfiedLinkError: Couldn't load BaiduMapVOS_v2_1_3: fi ...
- python pickle to json
ref: https://gist.github.com/Samurais/567ebca0f59c612eb977065008aad867 ''' Convert a pkl file into j ...
- XML案例(使用JAXP进行DOM解析)
1.book.xml <?xml version="1.0" encoding="UTF-8" standalone="no"?> ...