1116 Come on! Let's C (20 分)

"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 (≤10​4​​), 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?

题目大意:给出n个排名的id,序号代表排名,如果是第一名输出Mystery Award,素数名输出Minion,其他人输出Chocolate,重复查询提示。

水水的AC:

#include <iostream>
#include <algorithm>
#include<cstdio>
#include <map>
#include<cmath>
using namespace std; map<int,string> award;
map<int,int> query;
bool prime(int a){
int q=sqrt(a);
for(int i=;i<=q;i++){
if(a%i==){
return false;
}
}
return true;
}
int main()
{
int n,no;
scanf("%d",&n);
for(int i=;i<n;i++){
scanf("%d",&no);
if(i==){
award[no]="Mystery Award";
}else{
if(prime(i+)){
award[no]="Minion";
}else{
award[no]="Chocolate";
}
}
}
int m;
scanf("%d",&m);
for(int i=;i<m;i++){
scanf("%d",&no);
if(award.count(no)==){
printf("%04d: Are you kidding?\n",no);
}else {
if(query.count(no)==){
printf("%04d: Checked\n",no);
}else{//使用printf怎么输出String啊啊?好像没办法。。。
printf("%04d: ",no);
cout<<award[no]<<"\n";
query[no]=;
}
}
}
return ;
}

//有一个槽点,就是在写最后出现了个问题,代码中有注释,所以就混合使用printf和cout输出了,罪过。

1.查了一下发现是需要将其转换成char*类型,直接使用:

printf("%04d: %s\n",no,award[no].c_str());

即可!c_str()就是将string转换为char*的函数!!!

PAT 1116 Come on! Let's C [简单]的更多相关文章

  1. PAT 1002. A+B for Polynomials (25) 简单模拟

    1002. A+B for Polynomials (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue T ...

  2. PAT 1116 Come on! Let's C

    1116 Come on! Let's C (20 分)   "Let's C" is a popular and fun programming contest hosted b ...

  3. PAT Sign In and Sign Out[非常简单]

    1006 Sign In and Sign Out (25)(25 分) At the beginning of every day, the first person who signs in th ...

  4. PAT 1069 The Black Hole of Numbers[简单]

    1069 The Black Hole of Numbers(20 分) For any 4-digit integer except the ones with all the digits bei ...

  5. pat 1116 Come on! Let's C(20 分)

    1116 Come on! Let's C(20 分) "Let's C" is a popular and fun programming contest hosted by t ...

  6. PAT 甲级 1077 Kuchiguse (20 分)(简单,找最大相同后缀)

    1077 Kuchiguse (20 分)   The Japanese language is notorious for its sentence ending particles. Person ...

  7. PAT 甲级 1035 Password (20 分)(简单题)

    1035 Password (20 分)   To prepare for PAT, the judge sometimes has to generate random passwords for ...

  8. PAT 数列求和-加强版   (20分)(简单模拟)

    给定某数字A(1≤A≤9)以及非负整数N(0≤N≤100000),求数列之和S=A+AA+AAA+⋯+AA⋯A(N个A).例如A=1, N=3时,S=1+11+111=123 输入格式: 输入数字A与 ...

  9. PAT 1102 Invert a Binary Tree[比较简单]

    1102 Invert a Binary Tree(25 分) The following is from Max Howell @twitter: Google: 90% of our engine ...

随机推荐

  1. httpoxy 漏洞预警及修复方案

    影响范围 PHP.Go.Python等开启CGI(Client)模式的脚本语言 Language 环境依赖 HTTP Client PHP php-fpmmod_php Guzzle 4+Artax ...

  2. C++ c++与C语言的区别(空结构体)

    //区别⑨:空结构体声明(C++版本) #include<iostream> using namespace std; struct A{}; class B{}; void main() ...

  3. jira集成fisheye代码深度查看工具安装绿色版

    软件介绍: Fisheye 是一个源代码库深度查看软件,它可以挖掘源代码库中的有用信息,呈现在Web浏览器界面上,Fisheye优点: 1) Fisheye是一个基于Web的代码管理系统,可以与SVN ...

  4. 第二百八十节,MySQL数据库-外键链表之一对多,多对多

    MySQL数据库-外键链表之一对多,多对多 外键链表之一对多 外键链表:就是a表通过外键连接b表的主键,建立链表关系,需要注意的是a表外键字段类型,必须与要关联的b表的主键字段类型一致,否则无法创建索 ...

  5. 【BZOJ】1500: [NOI2005]维修数列(splay+变态题)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1500 模板不打熟你确定考场上调试得出来? 首先有非常多的坑点...我遇到的第一个就是,如何pushu ...

  6. Sublime 插件补充

    开启vim模式+autosave+Livereload插件 安装参考:emmmet http://www.cnblogs.com/wuheng1991/p/6144955.html

  7. 【转】虚拟串口VSPM解决串口编程问题

    通过串口调试软件 UartAssist.exe 和虚拟串口软件 VSPM,可以解决串口编程时没用硬件调试的问题,通过VSPM虚拟出串口设备,让程序发送信息到 VSPM 设备后通过 UartAssist ...

  8. CAEmitterCell 和 CAEmitterLayer具体解释

    一.在 UIKit 中,粒子系统由两部分组成: 1·      一个或多个  CAEmitterCells :发射器电池能够看作是单个粒子的原型(比如,一个单一的粉扑在一团烟雾).当散发出一个粒子,U ...

  9. C# 压缩和解压文件(SharpZipLib)

    先从网上下载ICSharpCode.SharpZipLib.dll类库 将文件或文件夹压缩为zip,函数如下 /// <summary> /// 压缩文件 /// </summary ...

  10. Spring_day04--HibernateTemplate介绍_整合其他方式_Spring分模块开发

    HibernateTemplate介绍 1 HibernateTemplate对hibernate框架进行封装, 直接调用HibernateTemplate里面的方法实现功能 2 HibernateT ...