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 ...
随机推荐
- Linux6.6及以上版本配置oracle-ASM共享储存-UDEV
在linux6.6版本之前,我们又两种方式可以配置asm共享磁盘,一种是安装asm驱动包进行asm磁盘组配置,另一种是UDEV通过识别共享存储UUID号进行asm磁盘组配置. 但在linux6.6之后 ...
- 利用python进行数据分析--pandas入门1
随书练习,第五章 pandas入门1 # coding: utf-8 # In[1]: from pandas import Series, DataFrame # In[2]: import pa ...
- Redis的消息订阅/发布 Utils工具类
package cn.cicoding.utils; import org.json.JSONException; import org.json.JSONObject; import redis.c ...
- 在Ubuntu16.04下安装SourceInsight和WeChat
1 使用Wine安装SourceInsight4 1.1 安装Wine $ sudo apt-get install wine 1.2 安装SourceInsight 下载SourceInsight软 ...
- Ubuntu启动 卡在checking battery state 解决方案
Ubuntu启动,卡在checking battery statALT + F1或者CTRL+ALT+F6切换到命令行[CTRL+ALT+F7返回界面]执行 sudo gdm start后就可以正常登 ...
- p5349 幂
分析 https://www.cnblogs.com/cjyyb/p/10822490.html 代码 #include<bits/stdc++.h> using namespace st ...
- 【洛谷P4445 【AHOI2018初中组】报名签到】
题目描述 n 位同学(编号从1 到n)同时来到体育馆报名签到,领取准考证和参赛资料.为了有序报名,这n 位同学需要按编号次序(编号为1 的同学站在最前面)从前往后排成一条直线.然而每一位同学都不喜欢拥 ...
- 自定义控件 - 切换开关:SwitchView
自定义控件一般的几个步骤:1.初始化相关背景图片,布局文件,自定义属性2.设置控件宽高OnMeasure()3.布局或者排版OnLayout()4.绘制控件OnDraw()5.处理触摸事件OnTouc ...
- Django学习之视图
一.Django的View(视图) 1.一个简单的视图 3.CBV和FBV 4.给视图加装饰器 使用装饰器装饰FBV 使用装饰器装饰CBV 二.Request对象和Response对象 1.reque ...
- day41—JavaScript运动的停止条件
转行学开发,代码100天——2018-04-26 前面学过了JavaScript运动的两种常用情形:匀速运动与缓冲运动.在这两种运动的处理过程中最大的区别在于速度的处理和到达目标点的处理. 即本文需要 ...