• 1116 Come on! Let‘s C


    "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 (≤104), 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:

    1. 6
    2. 1111
    3. 6666
    4. 8888
    5. 1234
    6. 5555
    7. 0001
    8. 6
    9. 8888
    10. 0001
    11. 1111
    12. 2222
    13. 8888
    14. 2222

    Sample Output:

    1. 8888: Minion
    2. 0001: Chocolate
    3. 1111: Mystery Award
    4. 2222: Are you kidding?
    5. 8888: Checked
    6. 2222: Are you kidding?
    1. #include
    2. #include
    3. #include
    4. #include
    5. using namespace std;
    6. bool isPrime[10010], vis[10010], have[10010];
    7. int n, k, x, cnt;
    8. int r[10010], Prime[10010];
    9. int main() {
    10. cin >> n;
    11. isPrime[1] = 1;
    12. for (int i = 2; i <= 10000; i++) {
    13. if (!isPrime[i]) {
    14. Prime[++cnt] = i;
    15. }
    16. for (int j = 1; j <= cnt && i * Prime[j] <= 10000; j++) {
    17. isPrime[i * Prime[j]] = 1;
    18. if (i % Prime[j] == 0) {
    19. break;
    20. }
    21. }
    22. }
    23. for (int i = 1; i <= n; i++) {
    24. cin >> x;
    25. r[x] = i;
    26. have[x] = 1;
    27. }
    28. cin >> k;
    29. while (k--) {
    30. cin >> x;
    31. cout << setw(4) << setfill('0') << x << ": ";
    32. if (!vis[x]) {
    33. if (!have[x]) {
    34. cout << "Are you kidding?" << endl;
    35. } else if (r[x] == 1) {
    36. cout << "Mystery Award" << endl;
    37. vis[x] = 1;
    38. } else if (!isPrime[r[x]]) {
    39. cout << "Minion" << endl;
    40. vis[x] = 1;
    41. } else {
    42. cout << "Chocolate" << endl;
    43. vis[x] = 1;
    44. }
    45. } else {
    46. cout << "Checked" << endl;
    47. }
    48. }
    49. return 0;
    50. }
  • 相关阅读:
    Flow 简单使用
    第三章 使用管理门户监视IRIS - 共享内存堆使用情况
    Matlab复习回顾919+920预习Lab1
    操作系统内存管理相关
    #每日一题合集#牛客JZ34-JZ43
    vue学习(基础下)
    面向过程程序设计——循环结构程序设计(2)
    有没有免费的视频剪辑软件?快来看看这些视频裁剪软件
    一文梳理SpringCloud常见知识点
    算法练习13——跳跃游戏II
  • 原文地址:https://blog.csdn.net/weixin_53199925/article/details/127547101