Coder

舒心、快乐,比什么都重要

1059 C语言竞赛 (20 分)

#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int arr[1 << 20];
int sushu(int t) {
    for (int i = 2; i <= sqrt(t); i++) {
        if (t % i == 0)
            return 1;
    }
    return 0;
}
int main() {
    int n, m, x, y;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> x;
        arr[x] = i;
    }
    cin >> m;
    while (m--) {
        cin >> y;
        if (arr[y] == -1) { // 奖品领过的不用标记
            cout << setw(4) << setfill('0') << y << ": " << "Checked" << endl;
            continue;
        }
        if (arr[y] == 1) {
            cout << setw(4) << setfill('0') << y << ": " << "Mystery Award" << endl;
            arr[y] = -1;
            continue;
        }
        if (arr[y] == 0) {  // 不在名单的不用标记
            cout << setw(4) << setfill('0') << y << ": " << "Are you kidding?" << endl;
            continue;
        }
        if (sushu(arr[y]) == 0) {
            cout << setw(4) << setfill('0') << y << ": " << "Minion" << endl;
            arr[y] = -1;
            continue;
        }
        cout << setw(4) << setfill('0') << y << ": " << "Chocolate" << endl;
        arr[y] = -1;
    }
    return 0;
}

 

posted @ 2019-04-24 01:23  H123K  阅读(180)  评论(0编辑  收藏  举报