• 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. }
  • 相关阅读:
    VM4.3 二次开发02 方案加载、执行及显示
    QT+OSG/osgEarth编译之十七:proj+Qt编译(一套代码、一套框架,跨平台编译,版本:通用坐标转换库proj-9.1.0)
    java毕业设计电影评论网站系统(附源码、数据库)
    最大int
    leetCode 283 移动零
    微信小程序——解决异步问题
    0067 练习
    Golang for 循环中的隐式内存别名问题
    【云原生 | Kubernetes 实战】04、k8s 名称空间和资源配额
    Go语言学习笔记—golang指针与结构体
  • 原文地址:https://blog.csdn.net/weixin_53199925/article/details/127547101