FJNU 1152 Fat Brother And Integer(胖哥与整数)

Time Limit: 1000MS   Memory Limit: 257792K

【Description】

【题目描述】

Fat brother recently studied number theory, him came across a very big problem — minimum does not appear positive integer. Fat brother get n positive integers, he needs to find out the least a positive integer and the positive integer is not in his n positive integers.

胖哥最近在学数论,他遇到了个重大问题— 最小未出现的正整数。胖哥有n个正整数,他需要找出不在这n个正整数中的最小正整数。

【Input】

【输入】

There are multiple test cases. The first line of input contains an integer T (T <= 25) indicating the number of test cases. For each test case:

The first line contains a single integer n (1 <= n <= 1000)

The second line contains n positive integer ai ( 1 <= ai <= 1000000000)

多组测试用例。

第一行是一个整数T(T <= 25)表示测试用例的数量。对于每个测试用例:

第一行是一个正整数n(1 <= n <= 1000)

第二行有n个正整数 ai( 1 <= ai <= 1000000000)

【Output】

【输出】

For each test case, output the minimum positive integer which didn’t appear in the n positive integer

对于每个测试用例,输出不在这n个正整数里出现的最小正整数

【Sample Input - 输入样例】

【Sample Output - 输出样例】

2

5

1 2 3 4 5

5

1 100 101 102 103

6

2

【题解】

最多就100个,直接暴力掉吧,注意下重复的元素就行了。

【代码 C++】

 #include<cstdio>
#include <algorithm>
int main(){
int t, n, i, data[];
while (~scanf("%d", &t)){
while (t--){
for (i = scanf("%d", &n); i <= n; ++i) scanf("%d", &data[i]);
std::sort(data, data + n + );
for (i = data[] = ; i < n && data[i + ] - data[i] < ; ++i);
printf("%d\n", ++data[i]);
}
}
return ;
}

FJNU 1152 Fat Brother And Integer(胖哥与整数)的更多相关文章

  1. FJNU 1154 Fat Brother And His Love(胖哥与女神)

    FJNU 1154 Fat Brother And His Love(胖哥与女神) Time Limit: 2000MS   Memory Limit: 257792K [Description] [ ...

  2. FJNU 1153 Fat Brother And XOR(胖哥与异或)

    FJNU 1153 Fat Brother And XOR(胖哥与异或) Time Limit: 1000MS   Memory Limit: 257792K [Description] [题目描述] ...

  3. FJNU 1155 Fat Brother’s prediction(胖哥的预言)

    FJNU 1155 Fat Brother’s prediction(胖哥的预言) Time Limit: 1000MS   Memory Limit: 257792K [Description] [ ...

  4. FJNU 1156 Fat Brother’s Gorehowl(胖哥的血吼)

    FJNU 1156 Fat Brother’s Gorehowl(胖哥的血吼) Time Limit: 1000MS   Memory Limit: 257792K [Description] [题目 ...

  5. FJNU 1151 Fat Brother And Geometry(胖哥与几何)

    FJNU 1151 Fat Brother And Geometry(胖哥与几何) Time Limit: 1000MS   Memory Limit: 257792K [Description] [ ...

  6. FJNU 1157 Fat Brother’s ruozhi magic(胖哥的弱智术)

    FJNU 1157 Fat Brother’s ruozhi magic(胖哥的弱智术) Time Limit: 1000MS   Memory Limit: 257792K [Description ...

  7. FJNU 1159 Fat Brother’s new way(胖哥的新姿势)

    FJNU 1159 Fat Brother’s new way(胖哥的新姿势) Time Limit: 1000MS   Memory Limit: 257792K [Description] [题目 ...

  8. Leetcode#13. Roman to Integer(罗马数字转整数)

    题目描述 罗马数字包含以下七种字符:I, V, X, L,C,D 和 M. 字符 数值 I 1 V 5 X 10 L 50 C 100 D 500 M 1000 例如, 罗马数字 2 写做 II ,即 ...

  9. HDU 4637 Rain on your Fat brother 线段与半圆和线段交 简单题

    题意: 应该不难读懂. 做法: 我们可以把雨滴看做静止不动,然后maze(这题的那个人)就是往左上方运动就可以了,计算出maze能跑到的最远的点,然后就是求起点和终点所构成的线段与每个雨滴交的时间,注 ...

随机推荐

  1. android 学习随笔十九(对话框、样式、主题、国际化 )

    1.对话框 package com.itheima.dialog; import android.os.Bundle; import android.app.Activity; import andr ...

  2. ssh-keygen+ssh-copy-id 在linux下实现ssh无密码登录访问(转)

    转自:http://blog.csdn.net/pennyliang/article/details/8556662 ssh-keygen+ssh-copy-id 在linux下实现ssh无密码登录访 ...

  3. mysql的内存表和临时表

    内存表: session $ mysql -uroot root@(none) ::>use test Database changed root::>CREATE TABLE tmp_m ...

  4. C# csv 操作类

    using System.Data; using System.IO; using System.Text; namespace YanZhiwei.DotNet2.Utilities.Common ...

  5. 【jQuery UI 1.8 The User Interface Library for jQuery】.学习笔记.8.Datepicker控件

    默认datepicker的安装启用 探索它的配置选项 安装启用一个触发按钮 配置一个供选择的动画 dateFormat选项 简单的国际化 多月datepicker 日期范围选择 datepicker的 ...

  6. svn搭建以及可能遇到的问题解决方案

    Svn服务器的安装和配置 1.安装svn服务器端软件从镜像服务器或者YUM源下载安装SVN服务器软件:yum install subversion mkdir /usr/local/svn //创建S ...

  7. 复利计算--4.0 单元测试之JAVA版-软件工程

    复利计算--4.0 单元测试-软件工程 前言:由于本人之前做的是C语言版的复利计算,所以为了更好地学习单元测试,于是将C语言版的复利计算修改为JAVA版的. 一.主要的功能需求细分: 1.本金为100 ...

  8. class打包成exe方式

    首先运行dos命令 jar -cvf **.jar *.class 把所有文件打包成jar包 用解压器打开jar包 打开meta-inf文件夹 打开用记事本打开main.mf文件 增加语句Main-C ...

  9. Paths on a Grid(简单组合数学)

    Paths on a Grid Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 23008 Accepted: 5683 Desc ...

  10. 使用jquery再次封装ajax

    $.fn.ajaxSend = function (type, url, postdata, onSuccess) { $.ajax({ async: false, url: url, type: t ...