第十八天PAT-A1144 The Missing Number简单模拟

PAT-ADVANCED1144——The Missing Number 我的PAT-ADVANCED代码仓:https://github.com/617076674/PAT-ADVANCED 原题链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805343463260160 题目描述: 题目翻译: 1144 丢失的数字 给定N个整数,你需要找出缺失的最小的正整数。 输入格... 阅读详情

A1142

Description:

找出不在给定序列的最小正整数;

思路:

  • 把序列中的数存在set里,从1开始顺序遍历找到不在set中的数就break输出;
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
using namespace std;

int main()
{
#ifdef ONLINE_JUDGE
#else
    freopen("1.txt", "r", stdin);
#endif // ONLINE_JUDGE
    int n;
    set<int>num;
    scanf("%d", &n);
    int t;
    while(n--){
        scanf("%d", &t);
        num.insert(t);
    }
    int ans = 1;
    while(num.find(ans)!=num.end())ans++;
    cout<<ans<<endl;
    return 0;
}
【PAT】A1144 The Missing Number【散列】 Given N integers, you are supposed to find the smallest positive integer that is NOT in the given list. Input Specification: Each input file contains one test case. For each case, the first line gives... 阅读详情

相关推荐

避坑指南:RK3576+Android14适配移远5G模组(RG200U)时,我遇到的3个‘巨坑’及解决方案

本文详细记录了RK3576芯片适配Android14系统与移远RG200U 5G模组过程中遇到的三大技术难题:RIL服务启动失败、HIDL兼容性矩阵配置错误及ttyUSB权限冲突。通过实战案例提供了动态库拷贝、HIDL版本链声明和SELinux策略调整等解决方案,帮助开发者高效完成5G模组集成,特别适用于基于kernel6.1的嵌入式开发场景。

weixin_30664051的博客 401

PAT(Advanced)1144 The Missing Number

PAT(Advanced)甲级1144 The Missing Number C++实现 题目链接 1144 The Missing Number 题目大意 给定一个整数序列,求解最小未出现在序列中的正整数 算法思路 根据题目要求,求解最小未出现在序列中的正整数,序列长度N最大为10e5,则说明该最小未出现的正整数必然小于等于N + 1,开辟数组大小至少为N+2,若输入的数为非正数或大于N则忽略,否则在布尔数组置对应下标的值为true,用于后续遍历布尔数组求解结果 AC代码 /* author : ecli

qq_44486439的博客 404

浅谈MOS管的发热原因和解决办法

解读一下开关管发热原因,解决方案和开关损耗测试。

qq_45508321的博客 1万+

PAT甲级1144 The Missing Number:[C++题解]哈希表

刷题

阿正的梦工坊 422

手把手教你用STM32单片机DIY一个简易PLC(附完整电路图与PCB文件)

本文详细介绍了如何利用STM32单片机DIY一个简易PLC控制器,涵盖硬件设计、电路图解析、PCB布局优化及固件框架实现。通过完整的电路图和PCB文件,帮助读者从元器件选型到工业级优化,逐步构建可靠的PLC系统,特别适合工业自动化爱好者和学习者实践。

weixin_42527160的博客 584

第4章 Stata参数检验

目录 4.1单一样本T检验 案例延伸 4.2独立样本T检验 案例延伸 1.改变置信水平 2.在异方差假定条件下进行假设检验 4.3配对样本T检验 案例延伸 1.改变置信水平 4.4单一样本方差的假设检验 案例延伸 4.5双样本方差的假设检验 参数检验(Parameter Test)是指对参数的平均值、方差、比率等特征进行的统计检验。参数检验一般假设统计总体的具体分布为已知,但是其中一些参数或者取值范围不确定,分析的主要目的是估计这些未知参数的取值,或者对这些参数进...

qq_45112156的博客 1万+

PAT_A1144#The Missing Number

Source: PAT A1144The Missing Number(20分) Description: Given N integers, you are supposed to find the smallest positive integer that is NOT in the given list. Input Specification: Eac...

weixin_34203426的博客 153

Windows Server 2012评估版过期自动关机问题:两种高效解决方案详解

本文针对Windows Server 2012评估版过期导致的自动关机问题,提供了两种高效解决方案。一是通过slmgr.vbs命令重置授权,临时延长评估期;二是使用DISM工具将评估版转换为正式版,一劳永逸。文章详细解析了两种方法的操作步骤、注意事项及适用场景,帮助用户快速恢复服务器稳定运行。

pytorchlight8的博客 1200

PAT A1144 The Missing Number

PAT A1144 The Missing Number Sample Input: 10 5 -25 9 6 1 3 4 2 5 17 Sample Output: 7 思路 1: 水一水,直接hash表,用数组的话要开很大,因为数据范围是不超过int大小,对应的hash数组下标也要达到int大小的边界,这里直接采用map code 1: #include <iostre...

qq_42347617的博客 175

[华为ensp]双核心的园区网

(给部分只会emm......借鉴的朋友提个醒,在group-member e0/0/2 to e0/0/20是所选,所以到了p l t那会给2-20端口都配置上trunk,别紧张,不是你问题)完成上述配置后,PC1可以ping通HTTP2服务器,Client1可以访问HTTP2服务器的HTTP站点,如果不能就要检查上述是否正确。本次实验主要目的是采用双核心的冗余网络,采用MSTP和VRRP技术,在核心层交换机上配置SC1上配置OSPF协议。SC1交换机上配置VRRP。在SC1上配置DHCP。

2301_78859499的博客 1421

基于STM32、HAL库的ICP-20100气压传感器 驱动程序设计

它具有低功耗、高精度、快速响应等特点,非常适合物联网、可穿戴设备和无人机等应用。#define ICP20100_FIFO_CTRL 0x09 // FIFO控制寄存器。#define ICP20100_FIFO_DATA 0x0A // FIFO数据寄存器。#define ICP20100_FIFO_STS 0x0B // FIFO状态寄存器。#define ICP20100_FIFO_WTM 0x15 // FIFO水印设置。

corlin6688的博客 606

【PAT甲级A1144】The Missing Number (20分)(c++)

1144 The Missing Number (20分) 作者:CHEN, Yue 单位:浙江大学 代码长度限制:16 KB 时间限制:200 ms 内存限制:64 MB Given N integers, you are supposed to find the smallest positive integer that is NOT in the given list. Input Specification: Each input file contains one test case. For

小庄同学的博客 223

全志V3S嵌入式驱动开发(uboot移植)

【 声明:版权所有,欢迎转载,请勿用于商业用途。 联系信箱:feixiaoxing @163.com】 安装了ubuntu操作系统,有了开发板,下面就可以进行我们的开发工作了。第一步,我们要面临的问题就是uboot移植。一般来说,嵌入式的基础环境就是uboot、linux和rootfs。uboot完成一些基本硬件的初始化,比如cpu频率设置、ddr初始化、加载linux等等。早前,uboot的烧入比较麻烦,需要jtag工具才能完成。现在来说,很多soc支持系统直接从sd卡启动,这对开发

嵌入式-老费,一个分享专业嵌入式知识的blog 2828

PAT(A) 1144 The Missing Number(C)统计

Description Given N integers, you are supposed to find the smallest positive integer that is NOT in the given list. Input Specification Each input file contains one test case. For each case, the first line gives a positive integer N (≤10​5​​). Then

wowpH 183

STM32F407中文手册

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

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

【PAT甲级 - C++题解】1144 The Missing Number

📣专栏定位:为想考甲级PAT的小伙伴整理常考算法题解,祝大家都能取得满分!

Newin2020的博客 529

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

PAT 甲级 1144  The Missing Number

1144The Missing Number(20 point(s)) Given N integers, you are supposed to find the smallest positive integer that is NOT in the given list. Input Specification: Each input file contains one test ...

漫浸天空的雨色的备忘录~ 636

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

PAT 1144 The Missing Number python解法

1144 The Missing Number (20 分) Given N integers, you are supposed to find the smallest positive integer that is NOT in the given list. Input Specification: Each input file contains one test case. For ...

qq_36936510的博客 281

PAT A-1144 The Missing Number

这题和柳神思路一样~我也用到了map,不过我的是int,bool型。找到最小的正数,该正数不在给定的数字列里。

Villanelle_w的博客 445

PAT 1144 The Missing Number

1144The Missing Number(20分) Given N integers, you are supposed to find the smallest positive integer that is NOT in the given list. Input Specification: Each input file contains...

weixin_30408739的博客 89

【PAT】A1144 The Missing Number (20 point(s))

文章目录A1144 The Missing Number (20 point(s))Input Specification:Output Specification:Sample Input:Sample Output: A1144 The Missing Number (20 point(s)) Given N integers, you are supposed to find the sma...

Duke 243

PAT - 1144 The Missing Number(20 分) || LeetCode 41. First Missing Positive

这道题同时在PAT和LeetCode中出现哈不过PAT并没有要求用 O(1)空间复杂,可是LeetCode要求用 O(1),时间复杂度都适用O(N);1144 The Missing Number(20 分)Given N integers, you are supposed to find the smallest positive integer that is NOT in the give...

qq_25175067的博客 299

PAT甲级 A1144 The Missing Number

pat甲级哈希表

biancheng_adai的博客 175

PAT-A1144 The Missing Number 题目内容及题解

Given N integers, you are supposed to find the smallest positive integer that is NOT in the given list. Input Specification: Each input file contains one test case. For each case, the first line giv...

BourbonWhiskey 的博客 498

PAT---1144 The Missing Number

参考这篇博文: https://blog.csdn.net/guoqingshuang/article/details/79786145 题目说在数据在int范围内,但网上也有说测试的最大值是100000,这说明PAT测试点还是不健壮啊,,,,个人认为这篇博文的方法符合题目要求。 #include &lt;stdio.h&gt; #include &lt;map&gt; using name...

上帝是个娘们的博客 156
上一篇: 第十八天PAT-A1142 Maximal Clique图论极大团判断模拟题
下一篇: 第十八天PAT-A1145 Hashing - Average Search Time哈希表及冲突处理模拟
Giggle1929
博客等级 码龄9年 2粉丝 106原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值