1144. The Missing Number (20)
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 (<= 105). 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 <map>
using namespace std; int main()
{
int n,d;
map<int,int> q;
cin>>n;
for(int i = ;i < n;i ++)
{
cin>>d;
q[d] = ;
}
d = ;
while(q[++ d]);
cout<<d;
}
1144. The Missing Number (20)的更多相关文章
- PAT 甲级 1144 The Missing Number (20 分)(简单,最后一个测试点没过由于开的数组没必要大于N)
1144 The Missing Number (20 分) Given N integers, you are supposed to find the smallest positive in ...
- PAT 1144 The Missing Number
1144 The Missing Number (20 分) Given N integers, you are supposed to find the smallest positive in ...
- PAT(A) 1144 The Missing Number(C)统计
题目链接:1144 The Missing Number (20 point(s)) Description Given N integers, you are supposed to find th ...
- [PAT] 1144 The Missing Number(20 分)
1144 The Missing Number(20 分) Given N integers, you are supposed to find the smallest positive integ ...
- PAT 1144 The Missing Number[简单]
1144 The Missing Number(20 分) Given N integers, you are supposed to find the smallest positive integ ...
- 1144 The Missing Number (20 分)
Given N integers, you are supposed to find the smallest positive integer that is NOT in the given li ...
- PAT 甲级 1144 The Missing Number
https://pintia.cn/problem-sets/994805342720868352/problems/994805343463260160 Given N integers, you ...
- 1144 The Missing Number
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 ...
随机推荐
- android开源框架thinkinandroid相关研究
和命令相关的类有: TAICommand:接口文件,一个命令接口所有命令需要从此实现,还有以下几种方法: TACommandExecutor 命令的实现类,其中含有commands这个成员变量.大部分 ...
- nodejs工作大全
1.修改文件夹中图片的名称 var fs = require('fs');var fileDirectory = "F:\\zdw\\修改文件夹名称\\newFile";var n ...
- Sublime如何设置背景透明
Sublime如何设置背景透明 下载sublime 透明背景插件 我用的是git下载插件: git clone https://github.com/vhanla/SublimeTextTrans.g ...
- python curl_get-pip.py Installing with get-pip.py
w curl https://bootstrap.pypa.io/get-pip.py > curl_get-pip.pypython curl_get-pip.py https://pip.p ...
- CTEX WinEdt 改变默认 pdf viewer
CTEX 2.9.2, WinEdt 7.0 "Options" -> "Excution Modes..." -> "PDF viewe ...
- AtomicBoolean 源码分析
AtomicBoolean AtomicBoolean 能解决什么问题?什么时候使用 AtomicBoolean? 可原子更新的 boolean 值 1)原子性:在Java中,对基本数据类型变量的读取 ...
- python-笔记(操作excel)
python操作excel,python操作excel使用xlrd.xlwt和xlutils模块,xlrd模块是读取excel的,xlwt模块是写excel的,xlutils是用来修改excel的.这 ...
- 阶段1 语言基础+高级_1-3-Java语言高级_04-集合_04 数据结构_1_数据结构_栈
2.1 数据结构有什么用? 当你用着java里面的容器类很爽的时候,你有没有想过,怎么ArrayList就像一个无限扩充的数组,也好像链表之类 的.好用吗?好用,这就是数据结构的用处,只不过你在不知不 ...
- 锐捷网络自动连接python脚本
1 实现锐捷网络的连接,当断开后自动重连 import os import sys import time ip = 'www.baidu.com' print('开始ping百度') backinf ...
- oracle--优化思路