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; }