hdu 5166 Missing number

题目连接

http://acm.hdu.edu.cn/showproblem.php?pid=5166

Missing number

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≤10)
For each test case , the first line contains a integers n , which means the number of numbers the permutation has. In following a line , there are n distinct postive integers.(1≤n≤1,000)

Output

For each case output two numbers , small number first.

Sample Input

2
3
3 4 5
1
1

Sample Output

1 2
2 3

#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<vector>
#include<map>
using std::map;
using std::min;
using std::find;
using std::pair;
using std::vector;
using std::multimap;
#define pb(e) push_back(e)
#define sz(c) (int)(c).size()
#define mp(a, b) make_pair(a, b)
#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cls(arr, val) memset(arr, val, sizeof(arr))
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define tr(c, i) for(iter(c) i = (c).begin(); i != (c).end(); ++i)
const int N = 1010;
const int INF = 0x3f3f3f3f;
bool vis[N];
void solve(int n) {
int v;
vector<int> ans;
cls(vis, false);
rep(i, n) {
scanf("%d", &v);
vis[v] = true;
}
rep(i, n + 2) {
if(!vis[i + 1]) ans.pb(i + 1);
}
printf("%d %d\n", ans[0], ans[1]);
}
int main() {
#ifdef LOCAL
freopen("in.txt", "r", stdin);
freopen("out.txt", "w+", stdout);
#endif
int t, n;
scanf("%d", &t);
while(t--) {
scanf("%d", &n);
solve(n);
}
return 0;
}
上一篇:Windows Server 2012设置WinDbg Kernel Debugging Local


下一篇:【学习笔记03】Javascript数组学习