-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcc_T22.cpp
More file actions
56 lines (45 loc) · 746 Bytes
/
cc_T22.cpp
File metadata and controls
56 lines (45 loc) · 746 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
Author : Abhinav
Modified : 19-07-2018 11:00:33 AM
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
#define faster ios_base::sync_with_stdio(false);cin.tie(0);
const ll mod = 1e9+7;
#define rep(i,j,k) for(ll i=j; i<k; i++)
#define repv(i,j,k) for(ll i=j; i>k; i--)
vi p(101,1);
void prime(){
int x=2;
p[1]=0;
while(x*x<=100){
for(int i=2*x; i<101; i+=x)
p[i]=0;
x++;
}
}
int main(){
faster;
prime();
ll t,n,x;
cin >> t;
while(t--){
cin >> n;
int flag1=0, min=INT_MAX;
rep(i,0,n){
cin >> x;
if(x==1){
flag1=1;
}
if(p[x] && x<min)
min = x;
}
if(flag1 && min!=INT_MAX)
cout << min << "\n";
else
cout << "-1\n";
}
return 0;
}