fork download
  1. #include <bits/stdc++.h>
  2. #include <ext/pb_ds/assoc_container.hpp>
  3. #include <ext/pb_ds/tree_policy.hpp>
  4.  
  5. using namespace std;
  6. using namespace __gnu_pbds;
  7. using ll = long long;
  8. using ld = long double;
  9.  
  10. #define all(x) x.begin(),x.end()
  11. #define v(x) vector<x>
  12. #define nl '\n'
  13. #define fxd(x) fixed << setprecision(x)
  14. template<class t> using ordered_set = tree<t, null_type, less<t>, rb_tree_tag, tree_order_statistics_node_update>;
  15. template<class t> using ordered_multiset = tree<t, null_type, less_equal<t>, rb_tree_tag, tree_order_statistics_node_update>;
  16.  
  17.  
  18. vector<bool> nums(1000005,true);
  19.  
  20. void sieve()
  21. {
  22. ll sz = nums.size()-1;
  23. for (ll i = 2; i <= sz; i++)
  24. {
  25. if(nums[i])
  26. {
  27. for (ll j = i*i; j <= sz; j+=i)
  28. {
  29. nums[j] = false;
  30. }
  31.  
  32. }
  33. }
  34. return;
  35. }
  36.  
  37. int main()
  38. {
  39. ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  40. nums[0] = false;
  41. nums[1] = false;
  42. ll n ; cin >> n;
  43. sieve();
  44. while (n--)
  45. {
  46. double x; cin >> x;
  47. double s = sqrt(x); ll w = s;
  48. if(s == (double)w && nums[w])
  49. {
  50. cout << "YES" <<nl;
  51. }
  52. else
  53. {
  54. cout << "NO" << nl;
  55. }
  56. }
  57.  
  58. }
Success #stdin #stdout 0.01s 5324KB
stdin
Standard input is empty
stdout
Standard output is empty