• 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. }
  • 相关阅读:
    DOS常用命令
    如何查询外文文献?
    MotionLayout的使用
    【linux命令讲解大全】056.updatedb命令:创建或更新slocate数据库文件
    基于STM32单片机的智能家居环境监测与控制系统设计
    如何做好一道数学题
    HTTPS的原理浅析与本地开发实践(下)
    “停车费”用英语怎么说?千万不要说Stop car money!柯桥BEC商务英语学习
    导外库失败显示错误:Failed to resolve
    04.OpenWrt-连接有线网络
  • 原文地址:https://blog.csdn.net/weixin_53199925/article/details/127547101