FJNU 1152 Fat Brother And Integer(胖哥与整数)
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(胖哥与整数)的更多相关文章
- FJNU 1154 Fat Brother And His Love(胖哥与女神)
FJNU 1154 Fat Brother And His Love(胖哥与女神) Time Limit: 2000MS Memory Limit: 257792K [Description] [ ...
- FJNU 1153 Fat Brother And XOR(胖哥与异或)
FJNU 1153 Fat Brother And XOR(胖哥与异或) Time Limit: 1000MS Memory Limit: 257792K [Description] [题目描述] ...
- FJNU 1155 Fat Brother’s prediction(胖哥的预言)
FJNU 1155 Fat Brother’s prediction(胖哥的预言) Time Limit: 1000MS Memory Limit: 257792K [Description] [ ...
- FJNU 1156 Fat Brother’s Gorehowl(胖哥的血吼)
FJNU 1156 Fat Brother’s Gorehowl(胖哥的血吼) Time Limit: 1000MS Memory Limit: 257792K [Description] [题目 ...
- FJNU 1151 Fat Brother And Geometry(胖哥与几何)
FJNU 1151 Fat Brother And Geometry(胖哥与几何) Time Limit: 1000MS Memory Limit: 257792K [Description] [ ...
- FJNU 1157 Fat Brother’s ruozhi magic(胖哥的弱智术)
FJNU 1157 Fat Brother’s ruozhi magic(胖哥的弱智术) Time Limit: 1000MS Memory Limit: 257792K [Description ...
- FJNU 1159 Fat Brother’s new way(胖哥的新姿势)
FJNU 1159 Fat Brother’s new way(胖哥的新姿势) Time Limit: 1000MS Memory Limit: 257792K [Description] [题目 ...
- 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 ,即 ...
- HDU 4637 Rain on your Fat brother 线段与半圆和线段交 简单题
题意: 应该不难读懂. 做法: 我们可以把雨滴看做静止不动,然后maze(这题的那个人)就是往左上方运动就可以了,计算出maze能跑到的最远的点,然后就是求起点和终点所构成的线段与每个雨滴交的时间,注 ...
随机推荐
- DirectX 绘制
先上图.后面会描写 ,细节
- 操作系统双语阅读 - Schedulers调度器2
Most processes can be described as either I/O bound or CPU bound. 大多数进程都可以描述为IO绑定或者CPU绑定. An I/O-bou ...
- linux设备驱动归纳总结(八):3.设备管理的分层与面向对象思想【转】
本文转载自:http://blog.chinaunix.net/uid-25014876-id-110738.html linux设备驱动归纳总结(八):3.设备管理的分层与面向对象思想 xxxxxx ...
- docker学习整理
1.安装 Docker 支持 CentOS6 及以后的版本 对于 CentOS6,可以使用 EPEL 库安装 Docker CentOS7 系统 CentOS-Extras 库中已带 Docker,可 ...
- IntelliJ IDEA---java的编译工具【转】
转自:http://baike.baidu.com/link?url=sEpS0rItaB9BiO3i-qCdGSYiTIVPSJfBTjSXXngtN2hBhGl1j36CYQORKrbpqMHqj ...
- Linux自动删除n天前备份
Linux是一个很能自动产生文件的系统,日志.邮件.备份等.因此需要设置让系统定时清理一些不需要的文件. 语句写法: find 对应目录 -mtime +天数 -name "文件名" ...
- JavaEE基础(十六)/集合
1.集合框架(去除ArrayList中重复字符串元素方式) A:案例演示 需求:ArrayList去除集合中字符串的重复值(字符串的内容相同) 思路:创建新集合方式 /** * A:案例演示 * 需求 ...
- 浏览器的不兼容,归纳几点html编码要素
1.文字本身的大小不兼容.同样是font-size:14px的宋体文字,在不同浏览器下占的空间是不一样的,ie下实际占高16px,下留白3px,ff下实际占高17px,上留白1px,下留白3px,op ...
- C#Winform常引用的库
1.DevExpress:引用其下的不同DLL,可操作使用不同的控件 2.IrisSkin2:引用对应的DLL后,代码如下 private Sunisoft.IrisSkin.SkinEngine s ...
- List与Set的contains方法效率问题
今天看到网上一篇文章说:Set检索元素效率低下,删除和插入效率高:List查找元素效率高,插入删除元素效率低.于是想到List虽然用get(index)方法查询效率高,但是若用contains方法查询 ...