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 ~