#include using namespace std; #include using namespace atcoder; using ll = long long; using VI = vector; using VVI = vector; using VL = vector; using VVL = vector; using VD = vector; using VVD = vector; using VS = vector; using P = pair; using VP = vector

; #define rep(i, n) for (ll i = 0; i < ll(n); i++) #define out(x) cout << x << endl #define dout(x) cout << fixed << setprecision(10) << x << endl #define all(a) (a).begin(),(a).end() #define rall(a) (a).rbegin(),(a).rend() #define sz(x) (int)(x.size()) #define re0 return 0 #define pcnt __builtin_popcountll template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } constexpr int inf = 1e9; constexpr ll INF = 1e18; //using mint = modint1000000007; using mint = modint998244353; int di[4] = {1,0,-1,0}; int dj[4] = {0,1,0,-1}; // https://youtu.be/UTVg7wzMWQc?t=2774 struct Sieve { int n; vector f, primes; Sieve(int n=1):n(n), f(n+1) { f[0] = f[1] = -1; for (ll i = 2; i <= n; ++i) { if (f[i]) continue; primes.push_back(i); f[i] = i; for (ll j = i*i; j <= n; j += i) { if (!f[j]) f[j] = i; } } } bool isPrime(int x) { return f[x] == x;} vector factorList(int x) { vector res; while (x != 1) { res.push_back(f[x]); x /= f[x]; } return res; } vector

factor(int x) { vector fl = factorList(x); if (fl.size() == 0) return {}; vector

res(1, P(fl[0], 0)); for (int p : fl) { if (res.back().first == p) { res.back().second++; } else { res.emplace_back(p, 1); } } return res; } }; //https://drken1215.hatenablog.com/entry/2023/05/23/233000#chap5 // A^N mod M template T pow_mod(T A, T N, T M) { T res = 1 % M; A %= M; while (N) { if (N & 1) res = (res * A) % M; A = (A * A) % M; N >>= 1; } return res; } bool MillerRabin(long long N, vector A) { long long s = 0, d = N - 1; while (d % 2 == 0) { ++s; d >>= 1; } for (auto a : A) { if (N <= a) return true; long long t, x = pow_mod<__int128_t>(a, d, N); if (x != 1) { for (t = 0; t < s; ++t) { if (x == N - 1) break; x = __int128_t(x) * x % N; } if (t == s) return false; } } return true; } bool is_prime(long long N) { if (N <= 1) return false; if (N == 2) return true; if (N % 2 == 0) return false; if (N < 4759123141LL) return MillerRabin(N, {2, 7, 61}); else return MillerRabin(N, {2, 325, 9375, 28178, 450775, 9780504, 1795265022}); } int main(){ Sieve sieve(5e5); VL ps; for(ll i = 1;i <= 1e5;i++){ if(sieve.isPrime(i)) ps.emplace_back(i); } ll q; cin >> q; rep(qi,q){ ll a; cin >> a; ll cnt = 0; for(ll i = 2;i*i*i <= a;i++){ if(!sieve.isPrime(i)) continue; if(a%i==0){ a /= i; cnt++; break; } } if(cnt == 0){ out("No"); continue; } bool ok = false; rep(i,sz(ps)){ if(a%ps[i] == 0){ a /= ps[i]; ok = true; break; } } if(ok && is_prime(a)) out("Yes"); else out("No"); } }