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能跑到的最远的点,然后就是求起点和终点所构成的线段与每个雨滴交的时间,注 ...
随机推荐
- Java随学随记
1.一个Java源文件可包含三个“顶级”要素: (1)一个包(package)声明(可选) (2)任意数量的导入(import)语句 (3)类(class)声明 该三要素必须以上顺序出现.即,任何导入 ...
- 【python cookbook】【数据结构与算法】1将序列分解为单独的变量
如果对象是可迭代的(任何序列),则可以进行分解操作,包括元组.列表.字符串.文件.迭代器以及生成器,可通过简单的一个赋值操作分解为单独的变量. 唯一要求:变量的总数和序列相吻合,否则将出错: Pyth ...
- WPF single instance
转自:http://www.cnblogs.com/z_lb/archive/2012/09/16/2687487.html public partial class App : Applicatio ...
- shell中读写mysql数据库
本文介绍了如何在shell中读写mysql数据库.主要介绍了如何在shell 中连接mysql数据库,如何在shell中创建数据库,创建表,插入csv文件,读取mysql数据库,导出mysql数据库为 ...
- MySQL Replication浅析
MySQL Replication是MySQL非常出色的一个功能,该功能将一个MySQL实例中的数据复制到另一个MySQL实例中.整个过程是异步进行的,但由于其高效的性能设计,复制的延时非常小.MyS ...
- Python入门学习笔记
了解 一下Python中的基本语法,发现挺不适应的,例如变量经常想去指定类型或者if加个括号之类的.这是在MOOC中学习到的知识中一点简单的笔记. Python的变量和数据类型: 1.Python这种 ...
- python: html
1. 三把利剑(html css js) css(颜色 位置) js (动) 2. 标签的分类:块级标签和行内标签 块级标签(div h p) 行内标签(span) 3. 标签存在的意义:为了方便操作 ...
- Cookie机制(会话cookie和持久化cookie)在客户端保持HTTP状态信息的方案
1. Cookie只有一个name和一个value,不同于map;购物车设计的时候需要cookie,获取购物车的cookie id,以便于将物品多次放入购物车: 2.cookie获取了其地址,并且可以 ...
- 简单的分页sql
select top 5 * from books where id not in(select top (5*(5-1)) id from Books order by id) order by i ...
- CentOS 安装Redis
redis是当前比较热门的NOSQL系统之一,它是一个key-value存储系统.和Memcached类似,但很大程度补偿了memcached的不足,它支持存储的value类型相对更多,包括strin ...