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)
  • 相关阅读:
    PNG 格式小图标的 CSS 任意颜色赋色技术
    CSS导航栏下划线跟随效果
    canvas 画表格、填数据、连线、拖拽、鼠标滚轮缩放
    【IE浏览器】GET请求防止读取缓存数据的解决方法
    JavaWeb——使用JavaBean
    数字签名——确保数据来源的可认证(鉴别)性和数据发送行为的不可否认性
    信息完整性验证技术——散列函数提供的消息认证技术
    OSI安全体系结构
    (持续更新)JavaScript
    (持续更新)SVN使用总结
  • 原文地址:https://www.cnblogs.com/h-hkai/p/12770656.html
Copyright © 2011-2022 走看看