PAT1059
程序员文章站
2022-07-15 14:03:43
...
#include<iostream>
#include <iomanip>
#include <cstdio>
#include<string>
#include<vector>
#include<array>
#include<math.h>
#include <ctype.h>
#include<algorithm>
#include <set>
using namespace std;
bool isprime(int num)
{//判断是否为素数
for (int i = 2; i <= sqrt(num); i++)
{
if (num%i == 0)
return false;
}
return true;
}
int main()
{
int a[10001], b[10001],c[10001]= { 0 };
int n,m,flag, i, j;
cin >> n;
for (i = 0; i < n; i++)
{
cin >> a[i];
}
cin >> m;
for (i = 0; i < m; i++)
{
cin >> b[i];
flag = 0;
for (j = 0; j < n;j++)
{
if (b[i] == a[j])
{
flag = 1;
if (c[j] == 0 && j == 0)
{
printf("%04d: Mystery Award\n", b[i]);
c[j] = 1;
}
else if(c[j] == 0 && isprime(j + 1))
{
printf("%04d: Minion\n", b[i]);
c[j] = 1;
}
else if(c[j] == 0 && !isprime(j+1))
{
printf("%04d: Chocolate\n", b[i]);
c[j] = 1;
}
else if (c[j] == 1)
{
printf("%04d: Checked\n", b[i]);
c[j] = 1;
}
}
}
if(!flag)
printf("%04d: Are you kidding?\n", b[i]);
}
return 0;
}