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 ...
随机推荐
- Python 中关于 round 函数的小坑
参考: http://www.runoob.com/w3cnote/python-round-func-note.html
- python爬虫之爬虫性能篇
一.首先想到的是for循环,单线程爬取每个url,但是如果有url出现了问题,后面的url就得等,性能低. 二.我们考虑线程池的问题,下面我们定义了线程池里面最多10个任务,也就是说最多同一时间只能有 ...
- 新版本macos无法安装mysql-python包
在更新了macos之后就发现无法正确安装python-mysql包了. 上网查阅了一下应该是c库或者osx的基础工具变动带来的问题.看到很多解决办法说使用pymysql,拜托我问的是如何安装pytho ...
- MySQL执行语句的顺序
MySQL的语句一共分为11步,最先执行的总是FROM操作,最后执行的是LIMIT操作.其中每一个操作都会产生一张虚拟的表,这个虚拟的表作为一个处理的输入,只是这些虚拟的表对用户来说是透明的,但是只有 ...
- MySQL系列:数据表基本操作(2)
1. 指定数据库 mysql> use portal; 2. 数据库表基本操作 2.1 查看数据表 mysql> show tables; +------------------+ | T ...
- mysql从入门到精通
解决MySQL Got a packet bigger than 'max_allowed_packet' bytes 问题在一次性向mysql插入的数据过大,可在my.ini中修改max_allow ...
- delphi 怎么实现主窗口退出时,有一个提示框?
无论点窗口上的[按钮]还是[右上角的叉],能出现一个提示窗口,“是”-退出窗口,“否”-重新登录(调出登录窗口),“取消”-返回.MessageBox能实现吗?还是要调用新窗口(我调用窗口,有些错误) ...
- solr安装配置(一)
本文使用的solr版本是solr-5.5.5. 步骤: 1.解压solr压缩包. 2.将solr-5.5.5\server\solr-webapp目录下面的文件拷贝到Tomcat的webapps目录下 ...
- Appium之编写H5应用测试脚本(切换到Webview)
App使用H5编写,默认方式找不到元素.启动后获取所有上下文,找到webivew_xxxx的,然后进行切换. 源码: package MyAppium; import io.appium.java_c ...
- Intel HD Graphics 620 (华硕FL5900U) Windows7下安装显卡驱动
我们的牙膏大厂Intel,不但会挤牙膏,现在连驱动也不给你用了.KabyLake也就是第七代酷睿处理器,集成了Intel HD Graphics 620核显,核显(显卡)驱动程序只支持到Win10这一 ...