#include #include #include typedef unsigned __int128 uint128_t; uint64_t modpow(uint64_t a, uint64_t n, uint64_t m){ uint64_t r; for(r=1;n;n/=2){ if(n&1) r = (uint128_t) r * a % m; a = (uint128_t) a * a % m; } return r; } int is_prime64(uint64_t n){ int i, j, r; uint64_t d; uint64_t as[] = {2, 325, 9375, 28178, 450775, 9780504, 1795265022}; if(n <= 1) return 0; if(n <= 3) return 1; if(!(n & 1)) return 0; r = __builtin_ctz(n-1); d = (n-1) >> r; for(i=0;i<7;i++){ uint64_t a = as[i]; uint64_t t = modpow(a, d, n); if(t == 0) return 1; if(t == 1) continue; for(j=0;t!=n-1;j++){ if(j == r-1) return 0; t = (uint128_t) t * t % n; if(t == 1) return 0; } } return 1; } int log3(uint64_t n){ int log2 = 63 - __builtin_clzll(n); return 1 + log2 * 0.630929753571457; } int kthroot(uint64_t n, int k){ uint64_t l = 1; uint64_t r = n; while(r - l > 1){ uint64_t m = (l + r) / 2; uint64_t mtk = pow(m, k); if(mtk == n) return m; else if(mtk < n) l = m; else r = m; } return 0; } int is_primepower(uint64_t n){ int i; if(n == 1) return 0; if(!(n&(n-1))) return 1; if(!(n&1)) return 0; for(i=log3(n);i>=2;i--){ int t = kthroot(n, i); if(t) return is_prime64(t); } return is_prime64(n); } int main(){ int i, q; scanf("%d", &q); for(i=0;i=n) puts("No"); else puts("Yes"); } } return 0; }