PAT (Basic Level) Practice (中文)1059 C语言竞赛 测试点3过不了,求解答
![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/797523743866170.png?x-oss-process=image/auto-orient,1/resize,w_320,m_lfit)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool isprime(int n)
{
for (int i = 2; i <= sqrt(n); i++)
if (n % i == 0)
return false;
return true;
}
int main()
{
int n;
cin >> n;
int id[10001] = {0};
for (int i = 0; i < n; i++)
{
int x;
cin >> x;
id[x] = i + 1;
}
int k;
cin >> k;
while (k--)
{
int y;
cin >> y;
if (id[y])
{
if (id[y] == 1)
printf("%04d: Mystery Award\n", y);
else if (isprime(id[y]) && id[y] != -1)
{
id[y] = -1;
printf("%04d: Minion\n", y);
}
else if (id[y] == -1)
printf("%04d: Checked\n", y);
else
{
id[y] = -1;
printf("%04d: Chocolate\n", y);
}
}
else
printf("%04d: Are you kidding?\n", y);
}
return 0;
}