-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path230B.cpp
42 lines (38 loc) · 925 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
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <iostream>
#include <algorithm>
#include <vector>
#include "math.h"
#include <map>
using namespace std;
bool is_prime(long long x) {
long long i = 2; while (i * i <= x){
if(x % i == 0) return false;
i++;
}
return true;
} // ivanistdoof
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
map<long long, bool> m;
int n; cin >> n; while(n--) {
long long x; cin >> x;
if(x == 1) cout << "NO\n";
else if(m.count(x))
cout << (m[x] ? "YES\n" : "NO\n");
else {
long long t = sqrt(x);
if((t * t == x) && is_prime(t)) {
cout << "YES\n";
m[x] = true;
}
else {
cout << "NO\n";
m[x] = false;
}
}
}
return 0;
}