Topic description The
C language contest is a joyous contest hosted by the School of Computer Science, Zhejiang University.
Since the theme of the competition is for fun, the awarding rules are also very funny:
- The champion will win a "mystery prize" (such as a huge collection of student research papers...).
- Students who rank in prime numbers will win the best prize-Minions dolls!
- Others will get chocolate.
Given the final ranking of the competition and the IDs of a series of contestants, you have to give the prizes that these contestants should receive.
Input format The
first line of input gives a positive integer N, which is the number of participants.
The next N rows give the final ranking, and each row gives a contestant's ID (4 digits) in the order of ranking.
Next, a positive integer K and K IDs to be queried are given.
Output format
, output in a row for each ID to be queried ID:
prizes,
- The prizes are either
Mystery Award
(Mystery Prize),Minion
(Minions), orChocolate
(Chocolate). - If the ID you are looking for is not in the ranking at all, print it
Are you kidding?
(what's the matter with me?). - If the ID has been checked (that is, the prize has already been received), print it
ID: Checked
(you can't eat more and take up more).
Input example
6
1111
6666
8888
1234
5555
0001
6
8888
0001
1111
2222
8888
2222
输出样例
8888: Minion
0001: Chocolate
1111: Mystery Award
2222: Are you kidding?
8888: Checked
2222: Are you kidding?
Range Data
N ≤ 10 . 4
Problem solution
mathematics:
#include <iostream>
#include <unordered_map>
using namespace std;
const int N = 10010;
int n, m;
string id;
unordered_map<string, int> Hash;
unordered_map<string, bool> used;
bool check(int x)
{
for (int i = 2; i <= x / i; i ++)
if(x % i == 0) return false;
return true;
}
int main()
{
cin >> n;
for (int i = 1; i <= n; i ++)
{
cin >> id;
Hash[id] = i;
}
cin >> m;
for (int i = 1; i <= m; i ++)
{
cin >> id;
cout << id << ": ";
if(!Hash.count(id)) cout << "Are you kidding?" << endl;
else if(used[id]) cout << "Checked" << endl;
else if(Hash[id] == 1) cout<< "Mystery Award" << endl;
else if(check(Hash[id])) cout << "Minion" << endl;
else cout << "Chocolate" << endl;
used[id] = true;
}
return 0;
}