#include
using namespace std;
int main() {
int q;
cin>>q;
for(int i=0;i<q;i++)
{
int no;
cin>>no;
int count=0;
for(int i=2;i<=(no/2);i++)
{
if((no%i)==0)
{
count++;
}
}
if(count==3)
{
cout<<“YES”<<endl;
}
else
{
cout<<“NO”<<endl;
}
}
return 0;
}
The Code here is showing TLE.
What can I do for that?
Like first I can calculate primes till that no. n(which is to be taken as input) by segmented sieve and then check if n is square from the list of primes.