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 (≤). 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:

  1. 10
  2. 5 -25 9 6 1 3 4 2 5 17

Sample Output:

  1. 7
  1. #include<iostream>
  2. #include<cstdio>
  3. #include<map>
  4. using namespace std;
  5. map<int,bool>mp;
  6. int main(){
  7. int N;
  8. scanf("%d", &N);
  9. for(int i = ; i < N; i++){
  10. int num;
  11. scanf("%d", &num);
  12. if(num > ){
  13. mp[num] = true;
  14. }
  15. }
  16. for(long long i = ; i < ; i++){
  17. if(mp.count(i) == ){
  18. printf("%lld", i);
  19. break;
  20. }
  21. }
  22. cin >> N;
  23. return ;
  24. }

A1144. The Missing Number的更多相关文章

  1. PAT A1144 The Missing Number (20 分)——set

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

  2. PAT_A1144#The Missing Number

    Source: PAT A1144 The Missing Number (20 分) Description: Given N integers, you are supposed to find ...

  3. Leetcode-268 Missing Number

    #268.  Missing Number Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find ...

  4. Missing number

    Missing number 题目: Description There is a permutation without two numbers in it, and now you know wh ...

  5. 【LeetCode】268. Missing Number

    Missing Number Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one ...

  6. hdu 5166 Missing number

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5166 Missing number Description There is a permutatio ...

  7. Missing Number, First Missing Positive

    268. Missing Number Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find th ...

  8. HDU 5166 Missing number 简单数论

    Missing number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) [ ...

  9. Missing number in array

    Given an array of size n-1 and given that there are numbers from 1 to n with one missing, the missin ...

随机推荐

  1. input type=date时,时间数据回填,报错The specified value "2019-0404-18" does not conform to the required format, "yyyy-MM-dd".

    <input autocomplete id="start-time" name="start_time" type="date" c ...

  2. Angular 基本指令

    <!DOCTYPE html><html ng-app><head lang="en"> <meta charset="UTF- ...

  3. vue 动态插入组件

    HTML代码: <div id="app"> <p>{{ message }}</p> <button @click="add( ...

  4. Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean (default-

    Maven项目报错:Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean (default-clea ...

  5. SpringBoot 4.SpringBoot 整合 devtools 实现热部署

    一.添加 devtools 依赖 <!-- Spring boot 热部署 : 此热部署会遇到 java.lang.ClassCastException 异常 --> <!-- op ...

  6. Java基础——对象容器(顺序、集合、Hash)

    扩展: For-each循环 for (String s: str) { System.out.println(s); } 等同于for (int i = 0; i < str.length; ...

  7. 建议3---理解Python与C语言的不同之处

    我们都知道,Python的底层是用C语言实现的,但切忌用C语言的思维和风格来编写Python代码.Python与其他语言有很多不同,以下来进行简单的分析: (1)"缩进"与“{}” ...

  8. shell中数组及其相关操作

    转载 https://blog.csdn.net/jerry_1126/article/details/52027539

  9. 莫烦scikit-learn学习自修第六天【特征值矩阵标准化】

    1.代码实战 #!/usr/bin/env python #!_*_coding:UTF-8 _*_ import numpy as np from sklearn import preprocess ...

  10. 老男孩python学习自修第十八天【面向对象】

    1.类与对象(构造方法与实例化) #!/usr/bin/env python # _*_ coding:UTF-8 _*_ class Province: def __init__(self, nam ...