HDU 5166, hdu5166

Source: Internet
Author: User

HDU 5166, hdu5166
HDU 5166 Time Limit: 1000 MS Memory Limit: 65536KB 64bit IO Format: % I64d & % I64u

Description

There is a permutation without two numbers in it, and now you know what numbers the permutation has. Please find the two numbers it lose.

 

Input

There is a number \ (T \) shows there are \ (T \) test cases below. ($ T \ leq 10 $)
For each test case, the first line contains a integers \ (n \), which means thenumber of numbers the permutation has. in following a line, there are $ n $ distinct postive integers. ($1 \ leq n \ leq 1,000 $)

 

Output

For each caseoutput two numbers, small number first.

 

Sample Input

2

3

3 4 5

1

1

 

Sample Output

1 2

2 3

Problem: Find the two missing numbers in a series (these two numbers must be the minimum two numbers ).

Note: Use the bool function to return 0 for all counts in the array.

 

# Include <stdio. h>

Int main ()
{
Int T, I;
Scanf ("% d", & T );
While (T --)
{
Int count, t = 0, j [2];
Scanf ("% d", & count );
Bool flag [1005] = {false };
For (I = 1; I <= count; I ++)
{
Int s;
Scanf ("% d", & s );
Flag [s] = true; // each input number of s is assigned a value of 1 to the second.
}

For (I = 1; I <= count + 2; I ++)
{
If (flag [I] = 0)
{
J [t ++] = I; // if there is zero, it is the missing number.
}
}
Printf ("% d \ n", j [0], j [1]);

}
Return 0;
}

More communication ~

Related Article

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.