Untitled
unknown
plain_text
2 years ago
706 B
8
Indexable
//Bai 5
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;
int p[1000001];
void sieve(){
for(int i = 0; i < 1000001; i++) p[i] = 1;
p[0] = p[1] = 0;
for(int i = 2; i <= 1000; i++){
if(p[i]){
for(int j = i*i; j <= 1000000; j+=i)
p[j] = 0;
}
}
}
map<ll,int> mp;
void tnum(){
for(int i = 2; i <= 1000000; i++){
if(p[i])
mp[i*i] = 1;
}
}
int main(){
freopen("TNUM.inp","r",stdin);
freopen("TNUM.out","w",stdout);
sieve();
tnum();
int n; cin >> n;
ll a[n];
for(int i = 0; i < n; i++) cin >> a[i];
for(int i = 0; i < n; i++){
if(mp[a[i]]) cout << "YES" << endl;
else cout << "NO" << endl;
}
return 0;
}Editor is loading...
Leave a Comment