PTA 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?
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <ctime>
#include <cctype>
#include <bitset>
#include <utility>
#include <sstream>
#include <complex>
#include <iomanip>
#include<climits>//INT_MAX

//#include<bits/stdc++.h>
#define PP pair<ll,int>
#define inf 0x3f3f3f3f
#define llinf 0x3f3f3f3f3f3f3f3fll
#define dinf 1000000000000.0
#define PI 3.1415926
typedef long long ll;
using namespace std;
int const mod=1e9+7;
const int maxn=1e5+10;
int n,q,x,a[10007];
int vis[10007];
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i){
        int x;
        scanf("%d",&x);
        a[x]=i;
        vis[x]=1;
    }
    scanf("%d",&q);
    for(int i=1;i<=q;++i){
        scanf("%d",&x);
        if(vis[x]==0)
            printf("%04d: Are you kidding?\n",x);
        else if(vis[x]==2)
            printf("%04d: Checked\n",x);
        else if(vis[x]==1){
            vis[x]=2;
            int fg=0;
            for(int j=2;j*j<=a[x];++j)
                if(a[x]%j==0)
                    fg=1;
            if(a[x]==1)
                printf("%04d: Mystery Award\n",x);
            else if(fg==0)
                printf("%04d: Minion\n",x);
            else if(fg==1)
                printf("%04d: Chocolate\n",x);
        }
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_44170305/article/details/108445981
今日推荐