Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- /*#include <ext/pb_ds/assoc_container.hpp>
- #include <ext/pb_ds/tree_policy.hpp> */
- using namespace std;
- //using namespace __gnu_pbds;
- #define endl '\n'
- #define pb push_back
- #define mp make_pair
- #define eb emplace_back
- #define ff first
- #define ss second
- #define ii pair < int, int >
- #define all(v) v.begin(), v.end()
- #define mem(a, b) memset(a, b, sizeof(a))
- #define f0(i,b) for(int i = 0; i < (b); i++)
- #define f1(i,b) for(int i = 1; i <= (b); i++)
- #define f2(i,a,b) for(int i = (a); i <= (b); i++)
- #define fr(i,b,a) for(int i = (b); i >= (a); i--)
- #define Debug(x) cout << #x " = " << (x) << endl
- #define fastio ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
- //#define ordered_set tree< ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update >
- // Constants
- const double PI = acos(-1.0);
- const double EPS = 1e-6;
- const int MOD = (int)1e9+7;
- const int maxn = (int)1e6+5;
- const int logn = 20;
- typedef long long int ll;
- typedef pair <int, ii> trie;
- typedef vector <int> vi;
- typedef vector <string> vs;
- typedef vector <bool> vb;
- typedef vector <vi> vvi;
- typedef vector <ii> vii;
- typedef vector <vii> vvii;
- typedef map <int, int> mii;
- typedef map <string, int> msi;
- typedef set <int> si;
- typedef bitset <maxn> bset;
- // Derection array
- int dr[] = { 1, 1, 0, -1, -1, -1, 0, 1 };
- int dc[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
- int dx[] = { 1, -1, 0, 0 };
- int dy[] = { 0, 0, 1, -1 };
- // GCD & LCM
- int gcd( int a, int b ) { return b ==0 ? a : gcd( b, a%b ); }
- int lcm( int a, int b ) { return a*( b/gcd( a, b ) ); }
- // Bit Operations
- inline bool check_bit( ll n, int i ) { return n&(1LL<<i); }
- inline ll set_bit( ll n, int i ) { return n|(1LL<<i); }
- inline ll reset_bit( ll n, int i ) { return n&(~(1LL<<i)); }
- // Some functions
- inline bool is_squre_root( ll x ) { ll s = sqrt(x); return (s*s==x); }
- inline bool is_power_of_two( ll x ) { return ((1LL<<(ll)log2(x))==x); }
- inline bool is_leap_year( ll year ) { return (year%400==0) || (year%4==0 && year%100!=0); }
- /*----------------------------------------- End Template ---------------------------------------------*/
- bset mark;
- void prime_sieve()
- {
- mark.set();
- mark[0] = mark[1] = 0;
- int limit = (int) sqrt( maxn*1.0 );
- for( int i = 4; i <= maxn; i += 2 ) mark[i] = 0;
- for( int i = 3; i <= maxn; i += 2 ){
- if( mark[i] ){
- if( i <= limit ){
- for( ll j = i*i; j <= maxn; j += (2*i) )
- mark[j] = 0;
- }
- }
- }
- }
- int main()
- {
- fastio
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- prime_sieve();
- int n;
- cin >> n;
- ll arr[n+1];
- f0( i, n )
- cin >> arr[i];
- f0( i, n ){
- int sq = sqrt( arr[i]*1.0 );
- if( (ll)sq*sq == arr[i] ){
- if( mark[sq] ) cout << "YES" << endl;
- else cout << "NO" << endl;
- }
- else cout << "NO" << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement