Missing number
Total Submission(s): 1178 Accepted Submission(s): 608
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 )
2 3 3 4 5 1 1
1 2 2 3
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[1005];
int main()
{
int t;
cin >> t;
while (t--)
{
memset(a, 0, sizeof(a));
int n;
cin >> n;
for (int i = 0; i < n; i++)
{
int x;
cin >> x;
a[x]++;
}
int ans[2], s = 0;
for (int i = 1; i < 1000 + 5; i++)
{
if (a[i] == 0)
{
ans[s] = i;
s++;
if (s == 2)
{
break;
}
}
}
cout << ans[0] << ' ' << ans[1] << endl;
}
return 0;
}
603




被折叠的 条评论
为什么被折叠?



