PAT 1116 Come on! Let's C [逻辑题] [素数判断]

MobaXterm终端工具个人学习版安装包及常用配置备份 资源包含 MobaXterm 个人版的安装包以及日常运维常用的基础配置备份文件。适用于网络工程师及运维人员用于日常的服务器管理、SSH 连接及串口调试。 压缩包内附带了个人整理的软件使用技巧与配置说明(仅供个人学习参考)。请各位同行下载后注意,技术工具请尽量支持官方正版,本资源仅供个人测试与交流使用,切勿用于商业环境。 立即下载

"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?

--------------------------------------这是题目和解题的分割线--------------------------------------

一道水题,如果是整型读入的话,记得输出格式得是%04d,不然无法保证0001这种样式的输出哈~

#include<cstdio>
#include<cmath>

using namespace std;

//素数判断 
int isPrime(int n)
{
	if(n<=1) return 0;
	int sqr = int(sqrt(n*1.0)),i;
	for(i=2;i<=sqr;i++)
		if(n%i==0) return 0;
	return 1;
}

int main()
{
	int rank[10005] = {},n,q,i;
	scanf("%d",&n);
	//数据很小,直接用数组存排名就行 
	for(i=1;i<=n;i++)
	{
		int tmp;
		scanf("%d",&tmp);
		rank[tmp] = i;
	}
	scanf("%d",&q);
	for(i=0;i<q;i++)
	{
		int tmp;
		scanf("%d",&tmp); 
		if(rank[tmp]==10005)
			printf("%04d: Checked\n",tmp);
		//这里把重复过和其余情况分开处理了 
		else
		{
			if(rank[tmp]==1)
				printf("%04d: Mystery Award\n",tmp);
			else if(isPrime(rank[tmp]))
				printf("%04d: Minion\n",tmp);
			else if(rank[tmp]==0)
				printf("%04d: Are you kidding?\n",tmp);
			else
				printf("%04d: Chocolate\n",tmp);
			//除了错误ID外,其余都标记为出现过 
			if(rank[tmp]!=0)
				rank[tmp] = 10005;
		}
	}
	return 0;
}

 

跟着Cell学单细胞转录组分析(五):单细胞转录组marker基因鉴定及细胞群注释 书接上回(跟着Cell学单细胞转录组分析(四):单细胞转录组测序UMAP降维聚类)。完成数据降维和细胞聚类后,最主要的环节和工作就是确定各个细胞群,明确是什么类型的细胞,正群的细胞定群很关键,涉及到整个研究,所以这一步宁愿多费时间,也不要出错。当然,这也不是一蹴而就的,需要反复的确认。 要确定各个群是什么细胞,首先需要了解细胞群的marker基因,因为不同类型的细胞突出 表达的基因也是不同的。这里使用FindAllMarkers鉴定各个细胞群的高表达基因。 DefaultAssay(scedata) 阅读详情

相关推荐

保姆级教程:用SSC Tool 5.13为先楫HPM6E00EVK生成8轴EtherCAT从站代码(含XML配置详解)

本文详细介绍了如何使用SSC Tool 5.13为先楫HPM6E00EVK开发板配置8轴EtherCAT从站,包括XML文件深度配置、代码生成与工程整合、烧录与调试技巧。教程涵盖从环境准备到性能优化的全流程,帮助开发者快速实现符合CIA402标准的8轴控制。

weixin_30352645的博客 255

PAT甲级——1116 Come on! Let's C (水题)

1116Come 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...

小熊猫的博客 274

基于Docker的D435i相机与IMU联合标定实战指南

本文详细介绍了基于Docker的D435i相机与IMU联合标定实战指南,涵盖kalibr镜像构建、IMU标定全流程、双目相机标定技巧及联合标定结果验证。通过Docker容器化部署,简化了复杂依赖环境,提升标定效率与精度,适用于机器人视觉与SLAM应用。

weixin_30872337的博客 239

判断素数的五种方法最全埃筛素数欧筛素数孪生素数

前言: 判断素数是编程中经常应用的实例,是编程学习的重要知识,那么下面我将介绍五种判断素数的方法。 定义: 素数是指在大于1的自然数中,除了1和它本身以外不再有其他因数的自然数。 简单来说就是,如果一个数只能被1和它本身整除,那么这个数就是素数。 比如:2 3 5 7 11 23… 0和1既不是素数也不是合数,2是最小的素数。 方法(一)暴力法 最简单最暴力的方法就...

m0_46260869的博客 7146

HINT: High-quality INpainting Transformer with Mask-Aware Encoding and Enhanced Attention 训练自己的数据集

HINT(高质量图像修复变换器)通过创新的掩码感知像素洗牌下采样模块(MPD)和空间激活通道注意力层(SCAL),显著提高了图像修复的质量,尤其在大面积缺失区域的情况下。实验表明,HINT在CelebA、CelebA-HQ、Places2和敦煌数据集上超越了现有的最先进模型,提升了图像的细节和结构一致性。

LJ1147517021的博客 312

STM32串口控制LED灯的亮灭

STM32中的串口控制LED灯的亮灭,分为两种方式,一种是直接发送数字0和1来控制灯的亮灭,另一种是通过发送字符串来控制。 我所使用的开发板主控芯片是STM32F401RET6,主频84MHz, 首先要进行串口的初始化: /* 函数功能:串口的初始化 函数名:Usart_Init 返回值:无 参数:u32 brr 备注: USART1_TXD->PA9 USART1_RXD->PA10 */ void Usart_Init(u32 brr) { float div; u16 div

博客 2万+

素数判断(4种方法,由简到难)

小于或等于n 且 与n互质的正整数的个数。

2402_87385120的博客 5385

Qt C++ HTTP 调用通义千问大模型 X 学术论文润色工具(SCI 格式适配)

请求地址:`https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation`;| Windows | 打包时携带 `Qt6Network.dll`/`libcrypto-1_1-x64.dll` 等依赖;| Linux | 安装 `libssl-dev` 和 `libcurl4-openssl-dev`;| API 调用失败 | 检查 API-KEY 是否有效;

寒寒豆豆软件公司的博客 104

素数(质数)判断的五种方法

素数判断的五种方法 素数的介绍 素数定义 质数(prime number)又称素数,有无限个。一个大于1的自然数,除了1和它本身外,不能被其他自然数整除,换句话说就是该数除了1和它本身以外不再有其他的因数;否则称为合数。 根据算术基本定理,每一个比1大的整数,要么本身是一个质数,要么可以写成一系列质数的乘积;而且如果不考虑这些质数在乘积中的顺序,那么写出来的形式是唯一的。最小的质数是2。                         --------360百科 第一种:暴力筛选法 思路分析 根据素数的

qq_43695957的博客 13万+

YOLOv8高级应用实战:多目标跟踪+实例分割+小样本检测(工业/安防场景落地指南)

安防监控中,需要跟踪多个行人的运动轨迹,而不只是框出“这是行人”;工业质检时,要精确分割出零件的缺陷区域(像素级),而不是只给一个粗略的矩形框;罕见场景下(如特殊故障检测、稀有动物识别),只能收集到几十张样本,普通训练方法精度惨不忍睹。我在落地工业安防和质检项目时,把YOLOv8的高级功能摸了个遍,踩过“多目标跟踪遮挡丢帧”“实例分割边缘模糊”“小样本检测过拟合”等一系列坑,最终总结出这套可直接复用的实战方案。多目标跟踪(ByteTrack)、实例分割、小样本检测。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 750

第9.3章 从CMake基础到自动驾驶实战:构建跨平台C/C++项目的全能指南

《CMake构建实战:项目开发卷》精要指南 本文系统梳理了许宏旭《CMake构建实战》核心内容,涵盖C++构建全流程: 基础构建:详解MSVC/GCC编译器使用、Makefile编写及静态/动态库构建方法 CMake核心:解析语法结构、变量控制、文件操作等关键命令,阐述项目全生命周期管理 实战应用:通过快速排序、手写数字识别项目演示现代CMake实践,特别针对自动驾驶领域给出多传感器融合、SLAM等场景的CMake配置方案 特色价值:本书填补了官方文档实例不足的空白,提供300+代码示例,是掌握工业级C++

行知SLAM 1343

PAT (Advanced Level) Practice 1116 Come on! Let's C

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,...

花とアリス殺人事件 361

2026年中科曙光嵌入式软件岗位面试题库(附参考答案)

嵌入式系统与C/C++基础摘要 硬件与外设总线 SPI总线:高速全双工同步串行接口,采用SCLK、MOSI、MISO和CS信号线,支持一主多从架构,典型应用于Flash存储、传感器等高速外设。 I2C总线:两线制低速串行总线(SDA/SCL),支持多主多从,需注意地址冲突和信号完整性。 时序约束:包括建立时间、保持时间、时钟周期等,是保障电路稳定运行的关键。 AD转换:将模拟信号转换为数字信号,应用于传感器采集、音频处理等场景。 PC寄存器:存储下一条指令地址,控制程序执行流,在跳转和中断时自动更新。 C/

Open 69

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

1116Come 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 ...

dggnqzt6462的博客 169

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

1116 Come on! Let's C -PAT甲级

"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...

amf12345的博客 152

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

PAT | A1116 Come on! Let's C

给出名次,第一得到Mystery Award,排名为素数的人得到Minion,其他人得到Chocolate #include <iostream> #include <unordered_set> #include <unordered_map> using namespace std; unordered_set<int> contestant...

yehonglin29的博客 139

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

1116. Come on! Let's C (20)[map]

1. 原题:https://www.patest.cn/contests/pat-a-practise/1116 2. 思路: 题意:基础逻辑题。 按照给定规则,判断某些查询的人该领取的奖项。 思路: 由于要对id随机查询,很容易想到用map。 利用map,把每个人的id和排名存到map里。 查询的时候检查该id的排名,根据排名输出奖项,同时排名设为-1. 这样为了重复访问时输出已

坚不萌 369

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 the College of Computer Science and Technology, Zhejiang University. Since the idea of the contest is for fun,...

Imagirl1的博客 346

PAT A1116 come on!Let's C (20)

#include #include #include #include using namespace std; map ranklist; const int MAX=10010; bool hasfound[MAX]={0}; vector query; vector result; int isprime(int n){ int len=sqrt(1.0*n); for(int i=2;

momottyy的专栏 368

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...

haohao0626的博客 252

【PAT】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...

elegant coder 452

(详解)--判断一个数是不是素数的问题

(JS代码)判断一个数是不是素数(质数):① 什么是素数(质数)?    只能被1和自身整除的数。② 代码逻辑:    我们可以推出除了1和本身,他们区间的数如果能被这个数整除,那么这个数就不是素数&lt;script&gt; /*判断一个数是不是质数*/ function isPrime(x) { for(var i = 2; i &lt; x; i++...

博客之家 2668

【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 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 Cham

C_greenbird的博客 248

素数的判断方法总结

参考博客:https://www.cnblogs.com/wpnan/p/4073852.html                  https://blog.youkuaiyun.com/f81892461/article/details/8582074                  https://blog.youkuaiyun.com/qq_34739984/article/details/52999528...

now 14万+

素数的一些逻辑题

1     打印出100以内的质数,一行显示5个,    (质数是只能被1跟自身整除的数,1不是质数)    public class Test4    {     public static void main(String args[])         {             boolean x = true;             int k = 0;       

Mr_Medal的博客 847

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 the College of Computer Science and Technology, Zhejiang University. Since the idea of the contest is for fun...

acm_zh的博客 314
上一篇: LeetCode [栈] 496.Next Greater Element I(C++和Python实现)
下一篇: PAT 1141 PAT Ranking of Institutions [map STL] [sort排序] [string类型的大小写转换]
DayDreammerⅠ
博客等级 码龄9年 9粉丝 122原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值