-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathH.cpp
More file actions
54 lines (41 loc) · 682 Bytes
/
Copy pathH.cpp
File metadata and controls
54 lines (41 loc) · 682 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
#include <bits/stdc++.h>
using namespace std;
const int N = 110000;
int p[N];
void sieve(void) {
for(int i = 0; i < N; i++)
p[i] = 1;
p[0] = p[1] = 0;
for(int i = 2; i < N; i++) {
if(p[i]) {
for(int j = i + i; j < N; j += i)
p[j] = 0;
}
}
}
void doCase(void) {
int n;
cin >> n;
int mnPrime, mxPrime;
mnPrime = mxPrime = -1;
for(int i = 0; i < n; i++) {
int x;
cin >> x;
if(p[x]) {
if(mnPrime == -1) mnPrime = mxPrime = i + 1;
else mxPrime = i + 1;
}
}
if(mnPrime != -1)
cout << mnPrime << " " << mxPrime << endl;
else
cout << "-1" << endl;
}
int main(void) {
sieve();
int t;
cin >> t;
while(t--)
doCase();
return 0;
}