• A1116. 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 (<=10000), 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?
     1 #include<cstdio>
     2 #include<iostream>
     3 #include<algorithm>
     4 #include<string>
     5 #include<queue>
     6 #include<math.h>
     7 using namespace std;
     8 int tb[10000] = {0}, N, K;
     9 int isPrime(int n){
    10     int sqr = sqrt(n * 1.0);
    11     if(n == 1)
    12         return 0;
    13     for(int i = 2; i <= sqr; i++){
    14         if(n % i == 0)
    15             return 0;
    16     }
    17     return 1;
    18 }
    19 char str[5][50] = {"Are you kidding?", "Mystery Award", "Minion", "Chocolate", "Checked"};
    20 int main(){
    21     scanf("%d", &N);
    22     int temp;
    23     for(int i = 1; i <= N; i++){
    24         scanf("%d", &temp);
    25         if(i == 1){
    26             tb[temp] = 1;
    27         }else if(isPrime(i) == 1){
    28             tb[temp] = 2;
    29         }else tb[temp] = 3;
    30     }
    31     scanf("%d", &K);
    32     for(int i = 0; i < K; i++){
    33         scanf("%d", &temp);
    34         printf("%04d: %s
    ", temp, str[tb[temp]]);
    35         if(tb[temp] != 0)
    36             tb[temp] = 4;
    37     }
    38     cin >> N;
    39     return 0;
    40 }
    View Code
  • 相关阅读:
    JVM 启动参数设置
    Linux文件分割与合并
    设置tomcat使用指定的jdk版本
    java字符编码
    HASH 哈希处理完数据导致数据集第一行数据缺失
    HASH 何时将key加载到h.definedata()中
    字符串 批量全角、半角转换
    SAS_正则表达式 字符意义
    正则表达式基础篇
    sas options有用的全局设置
  • 原文地址:https://www.cnblogs.com/zhuqiwei-blog/p/8576886.html
Copyright © 2020-2023  润新知