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 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:
10
5 -25 9 6 1 3 4 2 5 17
Sample Output:
7
- #include<iostream>
- #include<cstdio>
- #include<map>
- using namespace std;
- map<int,bool>mp;
- int main(){
- int N;
- scanf("%d", &N);
- for(int i = ; i < N; i++){
- int num;
- scanf("%d", &num);
- if(num > ){
- mp[num] = true;
- }
- }
- for(long long i = ; i < ; i++){
- if(mp.count(i) == ){
- printf("%lld", i);
- break;
- }
- }
- cin >> N;
- return ;
- }
A1144. The Missing Number的更多相关文章
- 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 ...
- PAT_A1144#The Missing Number
Source: PAT A1144 The Missing Number (20 分) Description: Given N integers, you are supposed to find ...
- Leetcode-268 Missing Number
#268. Missing Number Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find ...
- Missing number
Missing number 题目: Description There is a permutation without two numbers in it, and now you know wh ...
- 【LeetCode】268. Missing Number
Missing Number Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one ...
- hdu 5166 Missing number
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5166 Missing number Description There is a permutatio ...
- Missing Number, First Missing Positive
268. Missing Number Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find th ...
- HDU 5166 Missing number 简单数论
Missing number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) [ ...
- 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 ...
随机推荐
- 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 ...
- Angular 基本指令
<!DOCTYPE html><html ng-app><head lang="en"> <meta charset="UTF- ...
- vue 动态插入组件
HTML代码: <div id="app"> <p>{{ message }}</p> <button @click="add( ...
- 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 ...
- SpringBoot 4.SpringBoot 整合 devtools 实现热部署
一.添加 devtools 依赖 <!-- Spring boot 热部署 : 此热部署会遇到 java.lang.ClassCastException 异常 --> <!-- op ...
- Java基础——对象容器(顺序、集合、Hash)
扩展: For-each循环 for (String s: str) { System.out.println(s); } 等同于for (int i = 0; i < str.length; ...
- 建议3---理解Python与C语言的不同之处
我们都知道,Python的底层是用C语言实现的,但切忌用C语言的思维和风格来编写Python代码.Python与其他语言有很多不同,以下来进行简单的分析: (1)"缩进"与“{}” ...
- shell中数组及其相关操作
转载 https://blog.csdn.net/jerry_1126/article/details/52027539
- 莫烦scikit-learn学习自修第六天【特征值矩阵标准化】
1.代码实战 #!/usr/bin/env python #!_*_coding:UTF-8 _*_ import numpy as np from sklearn import preprocess ...
- 老男孩python学习自修第十八天【面向对象】
1.类与对象(构造方法与实例化) #!/usr/bin/env python # _*_ coding:UTF-8 _*_ class Province: def __init__(self, nam ...