Fjnu 1152 fat brother and integer (Fat Brother and whole number)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.