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 ...
随机推荐
- picker组件 label组件讲解
label组件:包住表单的组件,将里面的表单和label里的元素,紧紧的包在一起,当触发label里的元素,就相当于触发了表单组件 属性:for:类型 字符串 表单的 id 的值 picker组件:是 ...
- 数据库-SqlServer 行转列,列转行
两篇行转列,列转行的实例文章: 第1篇:https://www.cnblogs.com/cpcpc/archive/2013/04/08/3009021.html 第2篇:https://mp.wei ...
- java操作JSON字符串转换成对象的时候如何可以不建立实体类也能获取数据
引入依赖 <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson& ...
- Linux基础—saltstack运维工具学习
一.saltstack简介 1.saltstack是什么 系统管理员日常会进行大量的重复性操作,例如安装软件,修改配置文件,创建用户,批量执行命令等,如果主机数量庞大,单靠人工维护实在让人难以忍受. ...
- 红米note2 刷机 注意问题:
其他的百度都有,用刷线宝刷 红米note2 刷机 注意问题: 关机状态线下,链接电脑,按着音量下键不松手,按电源键开机后松开,即进入刷机模式. 其中,红米,红米1s移动,红米note移动3g/联通 ...
- Rxjava2不能再发射Null了
RxJava2的最大改变就是不能再流里发射Null了,有人会问发射了就怎么了,答案是你的流会因为NPE断开. 例如下面这段代码因为文件被删了找不到返回null,这时候就不触发下面Consumer的ac ...
- Dynamic Programming and Policy Evaluation
Dynamic Programming divides the original problem into subproblems, and then complete the whole task ...
- 浅谈vue$router 和 $route的区别
最近在学习vue的单页面应用开发,需要vue全家桶,其中用到了VueRouter,在路由的设置和跳转中遇到了两个对象$router 和 $route ,有些傻傻分不清,后来自己结合网上的博客和自己本地 ...
- Django报错[WinError 123] 文件名、目录名或卷标语法不正确。: '<frozen importlib._bootstrap
当你在项目文件中删除app对应的文件 却没有在项目url中删除之前配置的路径 也没有删除setting中配置的app 那么就会报错[WinError 123] 文件名.目录名或卷标语法不正确.: '& ...
- java高级开发面试总结
Java高级工程师面试题总结及参考答案 (转载)博客原文链接:https://www.cnblogs.com/java1024/p/8594784.html 一.面试题基础总结 1. JVM结构原理. ...