forked from anandadfoxx/codeforces_solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
230B.cpp
44 lines (36 loc) · 812 Bytes
/
230B.cpp
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
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define FOR(i, start, end) for(LL i = start; i < end; i++)
const LL constr = 1e7;
bool primes[constr+4];
bool isPrime(LL x) {
return primes[x];
}
void sieve() {
primes[1] = false;
primes[2] = true;
FOR(i, 2, constr+2) {
if (primes[i]) {
LL iter = i;
while (iter+i <= constr) {
iter += i;
primes[iter] = false;
}
}
}
}
int main() {
memset(primes, true, sizeof(primes));
sieve();
LL t;
cin >> t;
while (t--) {
LL x;
cin >> x;
double sqRoot = sqrt((double)x);
if (floor(sqRoot) == ceil(sqRoot) && isPrime((LL)sqRoot))
cout << "YES\n";
else cout << "NO\n";
}
}