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 (≤10​5​​). 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<cstdio>
const int maxn = ;
bool arr[maxn] = {false}; int main(){
int n;
scanf("%d",&n);
int num;
for(int i = ; i < n; i++){
scanf("%d",&num);
if(num > && num < maxn) arr[num] = true;
}
for(int i = ; i < maxn; i++){
if(arr[i] == false){
printf("%d",i);
return ;
}
}
return ;
}

最新文章

  1. 浏览器的兼容模式下的button中文字垂直方向不居中显示
  2. 移动端js知识总结
  3. php中CURL实现模拟登录并采集数据
  4. 【架构】RPC 使用 Haproxy、keepalive作为负载均衡
  5. RabbitMQ中 exchange、route、queue的关系
  6. Hello world S.B.S.
  7. UVa 11137 (完全背包方案数) Ingenuous Cubrency
  8. 基于AgileEAS.NET企业应用平台实现基于SOA架构的应用整合方案-开篇
  9. MySQL slave状态之Seconds_Behind_Master
  10. 在C#中使用属性控件添加属性窗口
  11. Ubuntu 查找命令
  12. SICP 习题 (1.37)解题总结
  13. (HTTPS)-tomcat 实现 https 登录,去掉端口号
  14. django-xadmin隐藏菜单不显示
  15. JavaScript中的alert、confirm、prompt
  16. android自动化必备之SDK
  17. android stuido搭配git常用命令
  18. MySQL数据库表损坏后的修复方法
  19. Haproxy Nginx cluster构建
  20. PHP冒泡排序-手写

热门文章

  1. Nginx 模块开发
  2. python 将字符串转化为可执行代码
  3. bootstrap页面效果图
  4. oracle数据库之分组查询
  5. 扫描工具——Meterpreter
  6. FreeMarker的实例通俗理解
  7. LSI SAS3008 RAID配置方法
  8. docker 镜像 容器删除
  9. Xamarin 笔记
  10. 严选 Android 路由框架优化(上篇)