题目链接
用两个map.一个是每个编号对应的奖品,一个是标记这个编号有没有出现过
注意测试点0和测试点1卡的是,如果这个编号重复且不在给定的有奖品的编号里面是要输出Are you kidding?的
#include<iostream>
#include<string>
#include<map>
#include<cmath>
using namespace std;
map<string, string>ans;
int judge(int n)
{
if (n == 1)
return 0;
for (int i = 2; i <= sqrt(n); i++)
{
if (n % i == 0)
return 0;
}
return 1;
}
map<string, int>flag;
int main()
{
int n;
cin >> n;
string s;
cin >> s;
ans[s] = "Mystery Award";
for (int i = 2; i < n+1; i++) {
cin >> s;
if (judge(i) == 1) {
ans[s] = "Minion";
}
else
ans[s] = "Chocolate";
}
cin >> n;
for (int i = 0; i < n; i++) {
cin >> s;
cout <<s<<": ";//这里卡的是测试点0和测试点1
if (flag[s] == 1&& ans[s] != "") {
cout << "Checked" << endl;
continue;
}
if (ans[s] == "")
cout << "Are you kidding?";
else {
cout << ans[s];
}
flag[s] = 1;
cout << endl;
}
return 0;
}