SHARE
TWEET

tprime

a guest Jul 22nd, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. #define ll long long int
  3. using namespace std;
  4. long long int prime[1000001];
  5. void sieve()
  6. {
  7.     prime[1] = 1;
  8.     for(ll i = 2;i<=1000000;i++)
  9.     {
  10.         if(prime[i] == 0)
  11.         {
  12.             for(ll j = i+i;j<=1000000;j+=i)
  13.             {
  14.                 prime[j] = 1;
  15.             }
  16.         }
  17.     }
  18. }
  19. int main()
  20. {
  21.     ll n,a;
  22.     cin>>a;
  23.  
  24.     for(ll i=0;i<a;i++)
  25.     {
  26.         cin>>n;
  27.         ll sqr=0;
  28.         sqr = sqrt(n);
  29.         sieve();
  30.         if(sqr*sqr==n&&prime[sqr]==0)
  31.         {
  32.             cout<<"YES"<<endl;
  33.         }
  34.         else
  35.         {
  36.             cout<<"NO"<<endl;
  37.         }
  38.     }
  39.     return 0;
  40. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top