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)
  • 相关阅读:
    发送trim值
    关一些时钟
    不同频率下的pwm配置
    c#鼠标在控件上面,然后显示文字
    C#通过文件路径截取对应的文件夹路径
    C#随机生成连续多少个十六进制数字
    C#检测串口被拔掉等一些触发事件合集
    c#按键Up和Down对Textbox的内容加1减1
    软件架构师工作历程
    软件架构阅读6
  • 原文地址:https://www.cnblogs.com/h-hkai/p/12770656.html
Copyright © 2011-2022 走看看