Guest User

Untitled

a guest
May 17th, 2020
808
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);
  9. cout.tie(0);
  10. long long n;
  11. cin >> n;
  12. vector <long long> a(n);
  13. for (long long i = 0; i < n; ++i)
  14. {
  15. cin >> a[i];
  16. long double s = sqrt(a[i]);
  17. if (s - floor(sqrt(a[i])) == 0)
  18. {
  19. bool flag = 1;
  20. if (a[i] == 1) flag = 0;
  21. else if (a[i] == 4) flag = 1;
  22. else if (a[i] % 2 == 0) flag = 0 ;
  23. else {
  24. for (long long j = 3; j*j <= sqrt(a[i]); j += 2)
  25. {
  26. if (a[i] % j == 0)
  27. {
  28. flag = 0;
  29. break;
  30. }
  31. }
  32. }
  33. if (flag) cout << "YES\n";
  34. else cout << "NO\n";
  35. } else cout << "NO\n";
  36. }
  37. }
Add Comment
Please, Sign In to add comment