Fjnu 1152 fat brother and integer (Fat Brother and whole number)
Time limit:1000ms Memory limit:257792k
"Description" |
"Title 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 integers His n positive integers. |
Fat Brother recently learning number theory, he encountered a major problem-the smallest non-appearing positive integer. Fat brother has n positive integers, and he needs to find the smallest positive integers that are not in the n positive integers. |
"Input" |
Input |
There is multiple test cases. The first line of input contains an integer t (t <=) 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) |
Multiple sets of test cases. The first line is an integer t (T <= 25) that represents the number of test cases. For each test case: The first line is a positive integer n (1 <= n <= 1000) The second line has n positive integers ai (1 <= ai <= 1000000000) |
"Output" |
Output |
For each test case, the output of the minimum positive integer which didn ' t appear in the n positive integer |
For each test case, the output is not the smallest positive integer that appears in these n positive integers |
"Sample Input-Enter sample" |
"Sample output-Output sample" |
2 5 1 2 3) 4 5 5 1 100 101) 102 103 |
6 2 |
Exercises
A maximum of 100, direct violence, pay attention to the repeated elements on the line.
"Code C + +"
1#include <cstdio>2#include <algorithm>3 intMain () {4 intT, N, I, data[1005];5 while(~SCANF ("%d", &t)) {6 while(t--){7 for(i = scanf ("%d", &n); I <= N; ++i) scanf ("%d", &data[i]);8Std::sort (data, data + N +1);9 for(i = data[0] =0; I < n && data[i +1]-Data[i] <2; ++i);Tenprintf"%d\n", ++data[i]); One } A } - return 0; -}
Fjnu 1152 fat brother and integer (Fat Brother and whole number)