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 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 分)的更多相关文章

  1. PAT 甲级 1144 The Missing Number (20 分)(简单,最后一个测试点没过由于开的数组没必要大于N)

    1144 The Missing Number (20 分)   Given N integers, you are supposed to find the smallest positive in ...

  2. 1144. The Missing Number (20)

    Given N integers, you are supposed to find the smallest positive integer that is NOT in the given li ...

  3. PAT 1144 The Missing Number

    1144 The Missing Number (20 分)   Given N integers, you are supposed to find the smallest positive in ...

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

    题目链接:1144 The Missing Number (20 point(s)) Description Given N integers, you are supposed to find th ...

  5. [PAT] 1144 The Missing Number(20 分)

    1144 The Missing Number(20 分) Given N integers, you are supposed to find the smallest positive integ ...

  6. PAT 1144 The Missing Number[简单]

    1144 The Missing Number(20 分) Given N integers, you are supposed to find the smallest positive integ ...

  7. PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) 凌宸1642 题目描述: A number that will ...

  8. PAT 甲级 1144 The Missing Number

    https://pintia.cn/problem-sets/994805342720868352/problems/994805343463260160 Given N integers, you ...

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

随机推荐

  1. 如何在CentOS里切换操作系统所用的语言,中英文切换

    操作系统CentOS 7.5,安装的时候选择的事中文,后来想改成英文 1.点左上角的“应用程序”---->再点“系统工具”----->“设置” 2.点“区域语言”,再点右侧的“汉语(中国) ...

  2. OVS的初始配置

    1.去掉bridge模块,为下面用OVS的模块奠定基础 rmmod bridge .insmod datapath/linux/openvswitch_mod.ko .insmod datapath/ ...

  3. JavaScript -- Array中的push()方法和concat()方法介绍

    Array => push()方法向数组的末尾添加一个或者多个元素,也就是说它会改变数组本身 concat() => concat()方法用于连接2个或者多个数组,但它的特殊之处在于,它会 ...

  4. Python基础入门-实现计算器多种姿势

    在Python中,虽然定义一个函数只需要def关键字,但是他能实现多种功能和用途,比如今天我们讲解的这几种方式.如何使用函数实现一个计算器的功能呢?当然,实现计算器的方式有很多种,我们举几个比较典型的 ...

  5. 如何将一个用utf-8编码的文本用java程序转换成ANSI编码的文本

    jdk有一个关于UTF-8的bug所以加了一句 br.skip(1); bugID: http://bugs.java.com/view_bug.do?bug_id=4508058 public st ...

  6. python -Tkinter 实现一个小计算器功能

    文章来源:http://www.cnblogs.com/Skyyj/p/6618739.html 本代码是基于python 2.7的 如果是对于python3.X  则需要将 tkinter 改为Tk ...

  7. POJ - 2586 Y2K Accounting Bug (找规律)

    Accounting for Computer Machinists (ACM) has sufferred from the Y2K bug and lost some vital data for ...

  8. Js 正则获取Html元素

    var html = $("#summaryTemplate").html(); var imageMath = /<img [^<,>]*(?=target-t ...

  9. 余额宝 vs. P2P网贷,谁更有生命力?

    余额宝跟P2P网贷作为一个理财方式,要说谁更有生命力,那就必须从以下几个方面说起,一是收益性,二是风险性,三是流动性,下面从这几个方面来对比一下余额宝跟P2P网贷. 首先是收益性,作为投资理财者,第一 ...

  10. windows下vscode 搭建python开发环境

    1.vscode https://code.visualstudio.com/ 下载 2.python下载 https://www.python.org/downloads/windows/  exe ...