zoukankan      html  css  js  c++  java
  • 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 (≤), 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:

    6
    1111
    6666
    8888
    1234
    5555
    0001
    6
    8888
    0001
    1111
    2222
    8888
    2222
    
     

    Sample Output:

    8888: Minion
    0001: Chocolate
    1111: Mystery Award
    2222: Are you kidding?
    8888: Checked
    2222: Are you kidding?

    思路:

      按照每种不同的情况输出就行了。

    Code:

     1 #include <bits/stdc++.h>
     2 
     3 using namespace std;
     4 
     5 bool isPrime(int n) {
     6     for (int i = 2; i * i <= n; ++i) {
     7         if (n % i == 0) return false;
     8     }
     9     return true;
    10 }
    11 
    12 int main() {
    13     int n, k;
    14     cin >> n;
    15     string id;
    16     map<string, int> list;
    17     for (int i = 1; i <= n; ++i) {
    18         cin >> id;
    19         list.insert({id, i});
    20     }
    21     cin >> k;
    22     set<string> visited;
    23     for (int i = 0; i < k; ++i) {
    24         cin >> id;
    25         if (list.find(id) == list.end()) {
    26             cout << id << ": Are you kidding?" << endl;
    27         } else if (visited.find(id) != visited.end()) {
    28             cout << id << ": Checked" << endl;
    29         } else if (list[id] == 1) {
    30             cout << id << ": Mystery Award" << endl;
    31         } else if (isPrime(list[id])) {
    32             cout << id << ": Minion" << endl;
    33         } else {
    34             cout << id << ": Chocolate" << endl;
    35         }
    36         visited.insert(id);
    37     }
    38 
    39     return 0;
    40 }
    永远渴望,大智若愚(stay hungry, stay foolish)
  • 相关阅读:
    格式化 | python笔记(1)
    在docker容器中部署python-selenium+chrome-headless自动化脚本(续)
    Jenkins+Postman+Newma+Xmysql之API全自动化测试
    1分钟搭建极简mock server
    绘图神器-matplotlib入门
    请务必每天早上8点将前十条科技要闻发给三爷
    请以excel管理你的接口测试用例
    如何优雅地使用httprunner进行接口测试
    一键压测工具改造(locust)
    shell中if的可判断的类型
  • 原文地址:https://www.cnblogs.com/h-hkai/p/12770656.html
Copyright © 2011-2022 走看看