unable to create boolean array of size greater than 10’000
#include <iostream>
#include <cmath>
#include <cstring>
using namespace std;
void primeSieve(bool p[],long n){
memset(p,0,n);
p[2] = 1;
for(long i=3;i<=n;i+=2){
p[i] = 1;
}
for(long i=3;i<=n;i+=2){
if(p[i]){
for(int j=i*i;j<=n; j += i){
p[j] = 0;
}
}
}
}
int main() {
long N = 1000000;
bool p[N]; // why give error n > 10000
primeSieve(p,N);
long long n;
cin>>n;
long long num;
while(n--){
cin>>num;
long long s = sqrt(num);
if(s*s == num && p[s])
cout<<"YES\n";
else
cout<<"NO\n";
}
}