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 (≤). 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<bits/stdc++.h>
using namespace std;
typedef long long ll; int a[]; int main(){
int n;
cin >>n;
for(int i=;i < n;i++){
cin >> a[i];
} sort(a,a+n); int cnt = ; for(int i=;i < n;i++){
if(a[i] > ){
if(a[i]>cnt){
cout << cnt;
return ;
}
else if(a[i] == cnt){
cnt++;
}
}
}
cout << cnt; return ;
}

做水题的感觉也太棒了8

 

PAT 1144 The Missing Number的更多相关文章

  1. PAT 1144 The Missing Number[简单]

    1144 The Missing Number(20 分) Given N integers, you are supposed to find the smallest positive integ ...

  2. [PAT] 1144 The Missing Number(20 分)

    1144 The Missing Number(20 分) Given N integers, you are supposed to find the smallest positive integ ...

  3. PAT 甲级 1144 The Missing Number (20 分)(简单,最后一个测试点没过由于开的数组没必要大于N)

    1144 The Missing Number (20 分)   Given N integers, you are supposed to find the smallest positive in ...

  4. PAT(A) 1144 The Missing Number(C)统计

    题目链接:1144 The Missing Number (20 point(s)) Description Given N integers, you are supposed to find th ...

  5. PAT 甲级 1144 The Missing Number

    https://pintia.cn/problem-sets/994805342720868352/problems/994805343463260160 Given N integers, you ...

  6. 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 ...

  7. 1144 The Missing Number (20 分)

    Given N integers, you are supposed to find the smallest positive integer that is NOT in the given li ...

  8. 1144. The Missing Number (20)

    Given N integers, you are supposed to find the smallest positive integer that is NOT in the given li ...

  9. 1144 The Missing Number

    Given N integers, you are supposed to find the smallest positive integer that is NOT in the given li ...

随机推荐

  1. sql server中的while循环语句

    语法格式: while 条件 begin ....... end declare @num begin update SDetail end

  2. A Boring Question (打表)

    题意:由m个0到n组合的数的相邻两项的组合数的乘积. 思路:好好打表!!!找规律!!! #include<bits/stdc++.h> using namespace std; typed ...

  3. Flask-Script

    其实本章就是为下一章做的铺垫啦,但是也要认真学习哦 Flask-Script 从字面意思上来看就是 Flask 的脚本 Django的启动命令是:python manager.py runserver ...

  4. python反反爬,爬取猫眼评分

    python反反爬,爬取猫眼评分.解决网站爬取时,内容类似:$#x12E0;样式,且每次字体文件变化.下载FontCreator . 用FontCreator打开base.woff.查看对应字体关系 ...

  5. FineReport中日期时间函数使用总结

    说明:凡函数中以日期作为参数因子的,其中日期的形式都必须是yy/mm/dd.而且必须用英文环境下双引号(" ")引用. DATE DATE(year,month,day):返回一个 ...

  6. Oarcle之group by关键字与having关键字

    group by关键字    *group by :分组由 作用: 用于对于查询的数据进行分组并进行处理 例如:select deptno ,job from emp group by deptno, ...

  7. 劳德巴赫下载kernel和文件系统时问题

    用劳德巴赫下载 kernel  dtb rootfs BOOT.bin 报错(记了个大概) Bad CRC Ramdisk image is corrupt or invalid 记得之前有人和我说r ...

  8. 算法(第四版)C# 习题题解——2.1

    写在前面 整个项目都托管在了 Github 上:https://github.com/ikesnowy/Algorithms-4th-Edition-in-Csharp 这一节内容可能会用到的库文件有 ...

  9. 换个角度聊聊FaaS

    Serverless/FaaS伴随着k8s的热度增加,也成为了热门话题.相关文章介绍了很多,这里笔者不一一赘述,而是从个人见解上聊聊关于FaaS的架构和意义. FaaS可能的架构优化 从AppEngi ...

  10. 用Python绘制一个感兴趣是数学公式图

    下面是函数sin,cos函数的图像: 代码如下: import numpy as np import pylab as pl import matplotlib.font_manager as fm ...