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 each case, the first line gives a positive integer N (≤105). Then N integers are given in the next line, separated by spaces. All the numbers are in the range of int.
Output Specification:
Print in a line the smallest positive integer that is missing from the input list.
Sample Input:
10
5 -25 9 6 1 3 4 2 5 17
Sample Output:
7
#include<cstdio>
const int maxn = ;
bool arr[maxn] = {false}; int main(){
int n;
scanf("%d",&n);
int num;
for(int i = ; i < n; i++){
scanf("%d",&num);
if(num > && num < maxn) arr[num] = true;
}
for(int i = ; i < maxn; i++){
if(arr[i] == false){
printf("%d",i);
return ;
}
}
return ;
}
1144 The Missing Number (20 分)的更多相关文章
- PAT 甲级 1144 The Missing Number (20 分)(简单,最后一个测试点没过由于开的数组没必要大于N)
1144 The Missing Number (20 分) Given N integers, you are supposed to find the smallest positive in ...
- 1144. The Missing Number (20)
Given N integers, you are supposed to find the smallest positive integer that is NOT in the given li ...
- PAT 1144 The Missing Number
1144 The Missing Number (20 分) Given N integers, you are supposed to find the smallest positive in ...
- PAT(A) 1144 The Missing Number(C)统计
题目链接:1144 The Missing Number (20 point(s)) Description Given N integers, you are supposed to find th ...
- [PAT] 1144 The Missing Number(20 分)
1144 The Missing Number(20 分) Given N integers, you are supposed to find the smallest positive integ ...
- PAT 1144 The Missing Number[简单]
1144 The Missing Number(20 分) Given N integers, you are supposed to find the smallest positive integ ...
- PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) 凌宸1642
PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) 凌宸1642 题目描述: A number that will ...
- PAT 甲级 1144 The Missing Number
https://pintia.cn/problem-sets/994805342720868352/problems/994805343463260160 Given N integers, you ...
- PAT Advanced 1019 General Palindromic Number (20 分)
A number that will be the same when it is written forwards or backwards is known as a Palindromic Nu ...
随机推荐
- 在Linux中监视IO性能
dd命令 iostat命令 理解iostat的各项输出 iostat的应用实例 附:在Windows中监视IO性能 延伸阅读 dd命令 dd其实是工作于比较低层的一个数据拷贝和转换的*nix平台的工具 ...
- ESP8266文档阅读ESP8266 SDK 入门指南
ESP8266 SDK 入门指南 1.概述 1.2.ESP8266 HDK 1.3.ESP8266 SDK 1.4.ESP8266 FW 1.5.ESP8266 工具集 2.1.开发板方案 3.软件 ...
- .Net插入大批量数据
1. 使用SqlDataAdapter /// <summary> /// 实现数据库事务,大批量新增数据 /// </summary> ...
- 编写高质量代码改善C#程序的157个建议——建议33:避免在泛型类型中声明静态成员
建议33:避免在泛型类型中声明静态成员 在上一建议中,已经理解了应该将MyList<int>和MyList<string>视作两个完全不同的类型,所以,不应该将MyList&l ...
- arcconf工具相关命令V1.0
arcconf工具相关命令V1.0 清除当前所有raid配置 Arcconf delete 1 array all #删除所有逻辑盘 Arcconf uninit 1 all ...
- Sql Server 公用表达式(CTE)
简介 对于select查询语句来说,通常情况下,为了使T-SQL代码更加简洁和可续,在一个查询中引入另外的结果集都是通过视图而不是子查询来进行分解的,但是,视图是作为系统对象存在数据库中,那对于结果集 ...
- 复杂业务下向Mysql导入30万条数据代码优化的踩坑记录
从毕业到现在第一次接触到超过30万条数据导入MySQL的场景(有点low),就是在顺丰公司接入我司EMM产品时需要将AD中的员工数据导入MySQL中,因此楼主负责的模块connector就派上了用场. ...
- 「HNOI2008」越狱
题目链接 戳我 \(Solution\) 正难则反,这道题直接做有点困难,但我们可以反过来思考我们可以用总方案数减去不可以越狱的方案数 首先来算总方案数: 对于每个房间的人都有\(M\)种宗教可以选, ...
- C# 接口(2)
接口的实现方式. 接口的实现分两种: 1 显示实现接口 2 实现接口. 我们前面所得的接口的实现均为实现接口.也就是第二种方式.那么我们来来看第第一种实现方式: interface IHuman { ...
- 玩转php缓存memcache
记录 一.本地安装 链接:https://www.cnblogs.com/jkko123/p/6294669.html 二.linux安装