• 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. }
  • 相关阅读:
    Rust 限流算法crate调研
    达梦、Oracle、PostgreSQL查询全部表备注,表字段,全部字段备注,全部索引,全部字段类型
    Web前端,HTML表格相关标签和属性,在网页中表格结构的显示
    原生JS中的Ajax
    面试题:经典常见排序算法 插入 冒泡 选择 归并 快速排序
    C++移动语义
    Docker从安装使用到配置各种镜像容器
    CSDN中: Markdown编辑器使用说明
    深度学习的进展,产业化,规模化、数据化
    【ARFoundation学习笔记】平面检测
  • 原文地址:https://blog.csdn.net/weixin_53199925/article/details/127547101