#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; unsigned xorshift() { static unsigned x=123456789, y=362436069, z=521288629, w=88675123; unsigned t=(x^(x<<11)); x=y; y=z; z=w; return w=(w^(w>>19))^(t^(t>>8)); } unsigned long long xorshift64() { unsigned long long a = xorshift(); a <<= 32; a |= xorshift(); return a; } long long modmul(long long a, long long b, long long mod) { long long ret = 0; for(int i=62; i>=0; --i){ ret *= 2; if(a & (1LL << i)) ret += b; ret %= mod; } return ret; } long long modpow(long long a, long long b, long long mod) { long long ret = 1; long long tmp = a; while(b > 0){ if(b & 1) ret = modmul(ret, tmp, mod); tmp = modmul(tmp, tmp, mod); b >>= 1; } return ret; } bool millerRabinPrimalityTest(long long n, int loop=10) { if(n < 2) return false; long long d = n - 1; int s = 0; while(d % 2 == 0){ ++ s; d /= 2; } while(--loop >= 0){ long long a = xorshift64() % (n - 1) + 1; long long x = modpow(a, d, n); if(x != 1){ bool isComposite = true; for(int r=0; r 0){ if(b & 1) ret *= tmp; tmp *= tmp; b >>= 1; } return ret; } void nthRoot(long long x, vector& ans) { ans.assign(1, -1); ans.push_back(x); for(int n=2; ans.back()>1; ++n){ long long left = 1; long long right = ans[n-1]; while(left < right){ long long mid = (left + right + 1) / 2; long long y = 1; long long tmp = mid; int a = n; while(a > 0){ if(a & 1) y = (tmp <= LLONG_MAX / y) ? y * tmp : LLONG_MAX; tmp = (tmp <= LLONG_MAX / tmp) ? tmp * tmp : LLONG_MAX; a >>= 1; } if(y <= x) left = mid; else right = mid - 1; } ans.push_back(left); } } bool solve(long long n) { if(n % 2 == 0){ if(n == 2) return false; else return true; } for(long long pa=2; pa q; nthRoot(qb, q); for(int b=1; b<(int)q.size(); ++b){ if(power(q[b], b) == qb && millerRabinPrimalityTest(q[b])) return true; } } return false; } int main() { int q; cin >> q; while(--q >= 0){ long long n; cin >> n; if(solve(n)) cout << "Yes" << endl; else cout << "No" << endl; } return 0; }