博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PAT甲级——A1116 Come on! Let's C
阅读量:4541 次
发布时间:2019-06-08

本文共 2387 字,大约阅读时间需要 7 分钟。

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

61111666688881234555500016888800011111222288882222

Sample Output:

8888: Minion0001: Chocolate1111: Mystery Award2222: Are you kidding?8888: Checked2222: Are you kidding?
1 #include 
2 #include
3 using namespace std; 4 int rankList[10000] = {
0};//存储排名 5 bool check[10000] = { false };//是否已经查询过 6 int n, k, id; 7 bool isPrime(int x) 8 { 9 if (x <= 3)10 return x > 1;11 for (int i = 2; i*i <= x; ++i)12 if (x%i == 0)13 return false;14 return true;15 }16 int main()17 {18 cin >> n;19 for (int i = 1; i <= n; ++i)20 {21 cin >> id;22 rankList[id] = i;23 }24 cin >> k;25 while (k--)26 {27 cin >> id;28 if (rankList[id] == 0)29 printf("%04d: Are you kidding?\n", id);30 else if (check[id] == true)31 printf("%04d: Checked\n", id);32 else if (rankList[id] == 1)33 printf("%04d: Mystery Award\n", id);34 else if (isPrime(rankList[id]))35 printf("%04d: Minion\n", id);36 else37 printf("%04d: Chocolate\n", id);38 check[id] = true;39 }40 return 0;41 }

 

转载于:https://www.cnblogs.com/zzw1024/p/11461369.html

你可能感兴趣的文章
消息中间件ActiveMQ、RabbitMQ、RocketMQ、ZeroMQ、Kafka如何选型?
查看>>
带宽的理解
查看>>
一、简单工厂模式
查看>>
查询出结果 给其 加上序号的方法 msql
查看>>
阶段1 语言基础+高级_1-3-Java语言高级_05-异常与多线程_第2节 线程实现方式_1_并发与并行...
查看>>
asp.net web.config配置节说明(转发)
查看>>
PPT幻灯片放映时无法全屏的解决方法
查看>>
开发中少不了的Fun -- 微信开发IOS端alert/confirm提示信息,去除网址(URL)的方法...
查看>>
Hibernate学习(二)
查看>>
java IO笔记(DataInput/DataOutput)
查看>>
Day8:String
查看>>
SQL语法之初级增删改查
查看>>
[转] Python基本学习资源收集汇总
查看>>
敏捷冲刺集合帖
查看>>
HTML5之Canvas
查看>>
团队作业8——第二次项目冲刺(Beta阶段)5.27
查看>>
彻底理解this指向
查看>>
hdu 3468(二分匹配)
查看>>
抑郁症的自我测试
查看>>
计算机编程以及基础原理
查看>>