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 ...
随机推荐
- longquan
/** * 登录后将数据填写到主数据 */ public void login(String login_nr) { //File f = new File(android.os.Environmen ...
- python学习笔记(5-1)-基本数据类型-字符串类型及操作
五.字符串处理函数 len(x):字符串x的长度.如len("12345")结果为5 str(x):任意类型x所对应的字符串形式. >>> str(123) ...
- ssl证书部署问题
问:我现在得到的ssl证书是.crt和.key两个在nginx环境下部署的证书,如果我们改用是tomcat,现在把这两个文件合成了.jks给tomcat使用,合成的时候输入的jks密码是不是就是部署在 ...
- Spring注解标签详解@Autowired @Qualifier等 @Slf4j
@Slf4j @Slf4j注解实现日志输出 自己写日志的时候,肯定需要: private final Logger logger = LoggerFactory.getLogger(LoggerTes ...
- python设计模式第八天【装饰器模式】
1.定义 使用包装的释放扩展类的功能,但是不使用继承 2.使用场景 3.代码实现 #!/usr/bin/env python #! _*_ coding:UTF-8 _*_ def MyDecorat ...
- 错误模块名称: KERNELBASE.dll错误
今天在部署一个C/S程序的时候出了bug,日志都没有记载:本地调试当然是没问题的,所以不是代码问题,百度之发现KERNELBASE.dll这个文章说的比较靠谱,仔细研究了自己的配置文件后,果然是配置文 ...
- Missing artifact com.oracle:ojdbc6:jar:11.2.0.3 Maven中不能引入ojdbc解决方法,错误
今天从服务器检出Maven项目的时候,遇到了一个问题,就是在pom.xml中引入ojdbc的jar包的时候出错了,提示是Missing artifact com.oracle:ojdbc6:jar:1 ...
- Java使用RabbitMQ之订阅分发(Topic)
使用RabbitMQ进行消息发布和订阅,生产者将消息发送给转发器(exchange),转发器根据路由键匹配已绑定的消息队列并转发消息,主题模式支持路由键的通配. 生产者代码: package org. ...
- 三、安装MyCat-Web
一.下载和解压MyCat-web http://dl.mycat.io/mycat-web-1.0/ wget http://dl.mycat.io/mycat-web-1.0/Mycat-web-1 ...
- P1020 导弹拦截
思路:贪心思路 拿比飞来的导弹高并且高度和飞来的导弹最相近的拦截系统去接, 如果全部都比导弹矮,那就新开一个拦截系统 #include<cstdio> #include<string ...