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)
  • 相关阅读:
    v-show 和 v-if 对 v-chart的影响
    vue axios get请求参数为json对象 而非字符串形式
    把对象字符化 和 把字符对象化
    vue 给url 中文参数 添加编码解码
    Observer(__ob__: Observer) 对象添加属性
    vux 使用swiper 垂直滚动文字 报错[Intervention] Ignored...
    vue 点击当前的标签,获取当前标签的value值
    css 写一个向右的箭头
    Unable to preventDefault inside passive event listener due to target being treated as passive
    在微信浏览器中分享到朋友圈回调函数失败问题
  • 原文地址:https://www.cnblogs.com/h-hkai/p/12770656.html
Copyright © 2011-2022 走看看