pat 1116 Come on! Let's C(20 分)

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 (≤10?4??), 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?
 1 #include <iostream>
 2 #include <algorithm>
 3 #include <cstdio>
 4 #include <cstring>
 5 #include <map>
 6 #include <stack>
 7 #include <vector>
 8 #include <queue>
 9 #include <set>
10 using namespace std;
11 const int MAX = 30;
12
13 int n;
14 // 0 Mystery Award 1 Minion  2 Chocolate
15 char s[MAX], ss[4][MAX] = {{"Mystery Award"}, {"Minion"}, {"Chocolate"}};
16 map <string, int> mp;
17 set <string> st;
18
19 bool is_prime(int x)
20 {
21     for (int i = 2; i * i <= x; ++ i)
22         if (x % i == 0) return false;
23     return true;
24 }
25
26 int main()
27 {
28 //    freopen("Date1.txt", "r", stdin);
29     scanf("%d%s", &n, &s);
30     mp[s] = 0;
31     for (int i = 2; i <= n; ++ i)
32     {
33         scanf("%s", &s);
34         if (is_prime(i)) mp[s] = 1;
35         else mp[s] = 2;
36     }
37
38     scanf("%d", &n);
39     while (n --)
40     {
41         scanf("%s", &s);
42         if (st.find(s) != st.end()) printf("%s: Checked\n", s);
43         else if (mp.find(s) == mp.end()) printf("%s: Are you kidding?\n", s);
44         else
45         {
46             printf("%s: %s\n", s, ss[mp[s]]);
47             st.insert(s);
48         }
49     }
50     return 0;
51 }

pat 1116 Come on! Let's C(20 分)

原文地址:https://www.cnblogs.com/GetcharZp/p/9582003.html

时间: 2024-11-05 21:42:16

pat 1116 Come on! Let's C(20 分)的相关文章

PAT乙级:1053 住房空置率 (20分)

PAT乙级:1053 住房空置率 (20分) 题干 在不打扰居民的前提下,统计住房空置率的一种方法是根据每户用电量的连续变化规律进行判断.判断方法如下: 在观察期内,若存在超过一半的日子用电量低于某给定的阈值 e,则该住房为"可能空置": 若观察期超过某给定阈值 D 天,且满足上一个条件,则该住房为"空置". 现给定某居民区的住户用电量数据,请你统计"可能空置"的比率和"空置"比率,即以上两种状态的住房占居民区住房总套数的百分

pat 1124 Raffle for Weibo Followers(20 分)

1124 Raffle for Weibo Followers(20 分) John got a full mark on PAT. He was so happy that he decided to hold a raffle(抽奖) for his followers on Weibo -- that is, he would select winners from every N followers who forwarded his post, and give away gifts.

PAT 乙级 1074 宇宙无敌加法器 (20 分)

1074 宇宙无敌加法器 (20 分) 地球人习惯使用十进制数,并且默认一个数字的每一位都是十进制的.而在 PAT 星人开挂的世界里,每个数字的每一位都是不同进制的,这种神奇的数字称为"PAT数".每个 PAT 星人都必须熟记各位数字的进制表,例如"--0527"就表示最低位是 7 进制数.第 2 位是 2 进制数.第 3 位是 5 进制数.第 4 位是 10 进制数,等等.每一位的进制 d 或者是 0(表示十进制).或者是 [2,9] 区间内的整数.理论上这个进制

PAT乙级1023. 组个最小数(20 分)

1023 组个最小数(20 分) 给定数字 0-9 各若干个.你可以以任意顺序排列这些数字,但必须全部使用.目标是使得最后得到的数尽可能小(注意 0 不能做首位).例如:给定两个 0,两个 1,三个 5,一个 8,我们得到的最小的数就是 10015558. 现给定数字,请编写程序输出能够组成的最小的数. 输入格式: 输入在一行中给出 10 个非负整数,顺序表示我们拥有数字 0.数字 1.……数字 9 的个数.整数间用一个空格分隔.10 个数字的总个数不超过 50,且至少拥有 1 个非 0 的数字

pat 1058 A+B in Hogwarts(20 分)

1058 A+B in Hogwarts(20 分) If you are a fan of Harry Potter, you would know the world of magic has its own currency system -- as Hagrid explained it to Harry, "Seventeen silver Sickles to a Galleon and twenty-nine Knuts to a Sickle, it's easy enough.

PAT 甲级 1027 Colors in Mars (20 分)

1027 Colors in Mars (20 分) People in Mars represent the colors in their computers in a similar way as the Earth people. That is, a color is represented by a 6-digit number, where the first 2 digits are for Red, the middle 2 digits for Green, and the

PAT 甲级 1054 The Dominant Color (20 分)

1054 The Dominant Color (20 分) Behind the scenes in the computer's memory, color is always talked about as a series of 24 bits of information for each pixel. In an image, the color with the largest proportional area is called the dominant color. A st

PAT 甲级 1058 A+B in Hogwarts (20 分) (简单题)

1058 A+B in Hogwarts (20 分)   If you are a fan of Harry Potter, you would know the world of magic has its own currency system -- as Hagrid explained it to Harry, "Seventeen silver Sickles to a Galleon and twenty-nine Knuts to a Sickle, it's easy enou

PAT 甲级 1104 Sum of Number Segments (20分)(有坑,int *int 可能会溢出)

1104 Sum of Number Segments (20分)   Given a sequence of positive numbers, a segment is defined to be a consecutive subsequence. For example, given the sequence { 0.1, 0.2, 0.3, 0.4 }, we have 10 segments: (0.1) (0.1, 0.2) (0.1, 0.2, 0.3) (0.1, 0.2, 0

PAT乙级1073-----多选题常见计分法 (20分)

1073 多选题常见计分法 (20分) 思路: 1.错选的和未选的都计入错误信息 2.错误信息的输出应该是  MAX某道题某选项的错误次数+题号+选项 首次通过代码: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 5 typedef struct answer{ 6 int s_sum; 7 int r_s_sum; 8 int score; 9 int w_sum; 10 int rig