1116. Come on! Let's C (20)

时间限制
200 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue

"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:

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? 思路 简单的逻辑题,记录下选手排名和是否已经给过奖品就行。注意没在排行榜上的id多次查询后还是输出"Are you kidding?"而不是"Checked"。 代码
#include<iostream>
#include<cstdio>
#include<map>
#include<math.h>
#include<vector>
using namespace std; bool isPrime(const int num)
{
if(num == )
return true;
if(num % == )
return false;
for(int i = ;i < num;i++)
{
if(num % i == )
return false;
}
return true;
} int main()
{
int N;
while(cin >> N)
{
map<int,bool> dic;
vector<int> rankList();
for(int i = ;i <= N;i++)
{
int number;
cin >> number;
dic.insert(pair<int,bool>(number,false));
rankList[number] = i ;
}
int K;
cin >> K;
for(int i = ;i <K;i++)
{
int query;
cin >> query;
printf("%04d",query);
if(dic.count(query) <= )
{
cout << ": Are you kidding?" << endl;
continue;
}
if(dic[query])
{
cout << ": Checked" << endl;
continue;
} if(rankList[query] == )
{
dic[query] = true;
cout << ": Mystery Award" << endl;
}
else if(isPrime(rankList[query]))
{
dic[query] = true;
cout << ": Minion" << endl;
}
else
{
dic[query] = true;
cout << ": Chocolate" << endl;
}
}
}
}

 

PAT1116: Come on! Let's C的更多相关文章

  1. PAT1116. Come on! Let's C (map)

    思路:模拟一下就好了,map用来记录每个人的排名. AC代码 #include <stdio.h> #include <map> #include <math.h> ...

随机推荐

  1. Xcode中的调试工具栏简介

    如下图所示: 从左至右,第一个按钮用来隐藏调试区域. 第二个按钮向你展示断点是否被全局开启或禁用.如果它不是高亮蓝色,则没有断点会被触发. 第三个按钮暂停或继续程序的执行,你一般点击它继续运行到程序的 ...

  2. android cookie持久化

    原博客地址:http://blog.csdn.net/shimiso/article/details/39033353 在解析网页信息的时候,需要登录后才能访问,所以使用httpclient模拟登录, ...

  3. Universal-Image-Loader,android-Volley,Picasso、Fresco和Glide图片缓存库的联系与区别

    Universal-Image-Loader,android-Volley,Picasso.Fresco和Glide五大Android开源组件加载网络图片比较 在Android中的加载网络图片是一件十 ...

  4. Android NDK开发三:java和C\C++交互

    转自:http://www.cnblogs.com/shangdahao/archive/2013/05/02/3053971.html 1.定义native方法并加载动态链接库: public cl ...

  5. ORACLE EBS AP invoice 到付款的数据流

    --1.Invoice创建时生成数据如下表 --Invoice主表 SELECT * FROM AP_INVOICES_ALL A WHERE A.INVOICE_NUM = '20111213001 ...

  6. MT6592 经验积累

    1.build/target/product/xxxx.mk  新项目clone后,需要修改这里 如:build/target/product/x160v.mk PRODUCT_MODEL :=Phi ...

  7. c/c++ 表达式求值

    表达式求值 [问题描述] 一个算术表达式是由操作数(operand).运算符(operator)和界限符(delimiter)组成的.假设操作数是正整数,运算符只含加减乘除等四种运算符,界限符有左右括 ...

  8. nasm预处理器(1)

    与处理器将所有以反斜杠结尾的连续行合并为一行. 单行的宏以%define来定义:当单行的宏被扩展后还含有其他宏时,会在执行时而不是定义时展开. %define a(x) 1+b(x) %define ...

  9. myeclipse10破解

    原本一直使用eclipse,但是写起web还是不太方便,由于idea使用不太顺手不太爱用.原来一直不能破解,今天迫不得已又拿起myeclipse仔细搞一番.下面是遇到的问题的总结. 不成功原因一:.原 ...

  10. 继续死磕SDRAM控制器

    SDRAM控制器 博主上一篇介绍了一些SDRAM的基本原理是否有必要学习使用纯Verilog写一个SDRAM控制器,接下来记录SDRAM控制器的工作原理.首先是上电初始化. 上电初始化 时序图中,tR ...