Advertisement
Guest User

Test

a guest
Feb 25th, 2020
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.33 KB | None | 0 0
  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.  
  8. #define endl '\n'
  9. #define pb push_back
  10. #define mp make_pair
  11. #define eb emplace_back
  12. #define ff first
  13. #define ss second
  14. #define ii pair < int, int >
  15. #define all(v) v.begin(), v.end()
  16. #define mem(a, b) memset(a, b, sizeof(a))
  17. #define f0(i,b) for(int i = 0; i < (b); i++)
  18. #define f1(i,b) for(int i = 1; i <= (b); i++)
  19. #define f2(i,a,b) for(int i = (a); i <= (b); i++)
  20. #define fr(i,b,a) for(int i = (b); i >= (a); i--)
  21. #define Debug(x) cout << #x " = " << (x) << endl
  22. #define fastio ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
  23. //#define ordered_set tree< ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update >
  24.  
  25. // Constants
  26. const double PI = acos(-1.0);
  27. const double EPS = 1e-6;
  28. const int MOD = (int)1e9+7;
  29. const int maxn = (int)1e6+5;
  30. const int logn = 20;
  31.  
  32. typedef long long int ll;
  33. typedef pair <int, ii> trie;
  34. typedef vector <int> vi;
  35. typedef vector <string> vs;
  36. typedef vector <bool> vb;
  37. typedef vector <vi> vvi;
  38. typedef vector <ii> vii;
  39. typedef vector <vii> vvii;
  40. typedef map <int, int> mii;
  41. typedef map <string, int> msi;
  42. typedef set <int> si;
  43. typedef bitset <maxn> bset;
  44.  
  45. // Derection array
  46. int dr[] = { 1, 1, 0, -1, -1, -1, 0, 1 };
  47. int dc[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
  48. int dx[] = { 1, -1, 0, 0 };
  49. int dy[] = { 0, 0, 1, -1 };
  50.  
  51. // GCD & LCM
  52. int gcd( int a, int b ) { return b ==0 ? a : gcd( b, a%b ); }
  53. int lcm( int a, int b ) { return a*( b/gcd( a, b ) ); }
  54.  
  55. // Bit Operations
  56. inline bool check_bit( ll n, int i ) { return n&(1LL<<i); }
  57. inline ll set_bit( ll n, int i ) { return n|(1LL<<i); }
  58. inline ll reset_bit( ll n, int i ) { return n&(~(1LL<<i)); }
  59.  
  60. // Some functions
  61. inline bool is_squre_root( ll x ) { ll s = sqrt(x); return (s*s==x); }
  62. inline bool is_power_of_two( ll x ) { return ((1LL<<(ll)log2(x))==x); }
  63. inline bool is_leap_year( ll year ) { return (year%400==0) || (year%4==0 && year%100!=0); }
  64.  
  65. /*----------------------------------------- End Template ---------------------------------------------*/
  66.  
  67. bset mark;
  68.  
  69. void prime_sieve()
  70. {
  71. mark.set();
  72.  
  73. mark[0] = mark[1] = 0;
  74. int limit = (int) sqrt( maxn*1.0 );
  75.  
  76. for( int i = 4; i <= maxn; i += 2 ) mark[i] = 0;
  77. for( int i = 3; i <= maxn; i += 2 ){
  78. if( mark[i] ){
  79. if( i <= limit ){
  80. for( ll j = i*i; j <= maxn; j += (2*i) )
  81. mark[j] = 0;
  82. }
  83. }
  84. }
  85. }
  86.  
  87. int main()
  88. {
  89. fastio
  90. #ifndef ONLINE_JUDGE
  91. freopen("input.txt", "r", stdin);
  92. freopen("output.txt", "w", stdout);
  93. #endif
  94.  
  95. prime_sieve();
  96. int n;
  97. cin >> n;
  98.  
  99. ll arr[n+1];
  100. f0( i, n )
  101. cin >> arr[i];
  102.  
  103. f0( i, n ){
  104. int sq = sqrt( arr[i]*1.0 );
  105. if( (ll)sq*sq == arr[i] ){
  106. if( mark[sq] ) cout << "YES" << endl;
  107. else cout << "NO" << endl;
  108. }
  109. else cout << "NO" << endl;
  110. }
  111.  
  112. return 0;
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement