Give
nn
n non-negative integers, please find the least non-negative integer that doesn’t occur in the
nn
n numbers.
输入:
The first line is an integer
TT
T, representing the number of test cases.
For each test case:
The first line of each test case is an integer
nn
n.
The second line of each test case are
nn
n non-negative integers
aia_i
a
i
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
map<unsigned,int> m;
int main(){
int t;
cin>>t;
while(t--){
m.clear();
int n;
cin>>n;
unsigned tmp;
for(int i=1;i<=n;i++){
scanf("%u",&tmp);
m[tmp]=1;
}
unsigned i=0;
while(i<=(1<<31)){
if(m[i]==0){
printf("%u\n",i);
break;
}
i++;
}
}
return 0;
}
A-Mex Query-2018年第二届河北省大学生程序设计竞赛
原文:https://www.cnblogs.com/-yjun/p/10800473.html