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 ...
随机推荐
- Dom4j解析
dom4j-1.6.1.jar, 这个包提供了xml解析相关的方法. 这里做一个记录,微信公众号里需要对HttpServletRequest做解析,实际上也可以用dom4j提供的方法进行解析转换. 这 ...
- mysql 允许特定IP访问
1. 测试是否允许远程连接 $ telnet 192.168.1.8 3306 host 192.168.1.4 is not allowed to connect to this mysql s ...
- 数据库管理 trove openstack
Trove是数据库即服务的OpenStack.它旨在完全基于OpenStack运行,其目标是允许用户快速轻松地利用关系数据库的功能,而无需处理复杂的管理任务.云用户和数据库管理员可以根据需要配置和管理 ...
- 洛谷P3870开关题解
我们先看题面,一看是一个区间操作,再看一下数据范围,就可以很轻松地想到是用一个数据结构来加快区间查询和修改的速度,所以我们很自然的就想到了线段树. 但是这个题还跟普通的线段树不一样,这个题可以说要思考 ...
- 大学jsp实验6session
1.session对象的使用 (1)设计一个简单的在线问卷调查程序,共有3个页面,分别是one.jsp.two.jsp.three.jsp. 其中,shiyan6_1_one.jsp页面效果如下图所示 ...
- 【CTSC2017】【BZOJ4903】吉夫特 卢卡斯定理 DP
题目描述 给你一个长度为\(n\)的数列\(a\),求有多少个长度\(\geq 2\)的不上升子序列\(a_{b_1},a_{b_2},\ldots,a_{b_k}\)满足 \[ \prod_{i=2 ...
- Git回滚代码暴力法
Git回滚有多种方式,这里使用的是[强制提交到远程分支] 效果为:如回滚前的提交记录是 1.2.3.4,使用这种方法回滚到2,那么提交记录就变成了1.2. 操作方法: 需要在本地的Git仓库,右键选择 ...
- mysql索引技巧
索引 索引是对数据表一列或多列的值进行排序的一种结构,用于加速基于索引字段的数据排序以及优化查询的执行速度,避免全表扫描.索引是直接影响数据库性能的数据库模式对象,因此十分重要.在定义主键和唯一键约束 ...
- PHP linux ZendGuardLoader.so: undefined symbol: executor_globals
/usr/xxx/php xxx/xxx.php 报了这个错. 本人出现此问题的原因: php执行程序路径错了. 解决: linux下执行 which php 命令 查看php真实路 ...
- rt-thread之stm32系列BSP制作方法
@2019-01-24 [小记] bsp制作方法: 官网下载 rt-thread 源码,将路径 bsp/stm32/libraries/templates/ 下的模板文件,Copy至路径 bsp/st ...