fork download
  1. #include <bits/stdc++.h>
  2. typedef long long ll;
  3. using namespace std;
  4. void FastCode() {
  5. std::ios_base::sync_with_stdio();
  6. cin.tie(0);
  7. cout.tie(0);
  8. }
  9. bool prime(ll n) {
  10.  
  11.  
  12. for (int j = 2; j <= sqrt(n); j++) {
  13. if (n % j == 0) {
  14. return false;
  15. }
  16. }
  17.  
  18.  
  19. }
  20. int main()
  21. {
  22. FastCode();
  23. ll n;
  24. cin >> n;
  25. ll arr[100005]{ 0 };
  26. for (int i = 0; i < n; i++) {
  27. cin >> arr[i];
  28. }
  29. for (int i = 0; i < n; i++) {
  30. ll z = sqrt(arr[i]);
  31. if (z * z == arr[i] && z != 1) {
  32. if (prime(z)==false) {
  33. cout << "NO" << endl;
  34. }
  35. else {
  36. cout << "YES" << endl;
  37. }
  38.  
  39. }
  40. else {
  41. cout << "NO" << endl;
  42. }
  43.  
  44. }
  45.  
  46.  
  47. return 0;
  48. }
Success #stdin #stdout 0.01s 5348KB
stdin
Standard input is empty
stdout
Standard output is empty