Guest User

Untitled

a guest
Dec 10th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <bitset>
  4. #include <vector>
  5. #define DN 10000005
  6. #define LL long long
  7. using namespace std;
  8.  
  9. int n;
  10. LL nr;
  11. vector<LL> pr;
  12.  
  13. bitset<DN> isp;
  14.  
  15. void c() {
  16. for(int i=2; i*1LL*i<DN; ++i) if(!isp[i]) {
  17. pr.push_back(i);
  18. for(int j=i*i; j<DN; j+=i) isp[j]=1;
  19. }
  20. }
  21.  
  22. bool ok(LL nr) {
  23. for(int i=0; i<pr.size(); ++i) if(pr[i]*pr[i]==nr) return 1;
  24. return 0;
  25. }
  26.  
  27. int main()
  28. {
  29. c();
  30. cin>>n;
  31. for(int i=1; i<=n; ++i) {
  32. cin>>nr;
  33. if(nr<4) {
  34. cout<<"NO\n";
  35. continue;
  36. }
  37. if(ok(nr)) cout<<"YES\n";
  38. else cout<<"NO\n";
  39. }
  40. return 0;
  41. }
Add Comment
Please, Sign In to add comment