#include #include #include typedef unsigned __int128 uint128_t; uint64_t s[2] = {0xFEDCBA9876543210, 0x0123456789ABCDEF}; uint64_t xorshift128plus(void) { uint64_t x = s[0]; uint64_t const y = s[1]; s[0] = y; x ^= x << 23; s[1] = x ^ y ^ (x >> 17) ^ (y >> 26); return s[1] + y; } 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_prime(uint64_t n){ int i, j, r; uint64_t d; if(n == 1) return 0; if(n == 2) return 1; if(n == 3) return 1; if(!(n & 1)) return 0; r = __builtin_ctz(n-1); d = (n-1) >> r; for(i=0;i<10;i++){ uint64_t a = 2 + xorshift128plus() % (n-3); uint64_t t = modpow(a, d, n); 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>=1;i--){ int t = kthroot(n, i); if(t) return is_prime(t); } return is_prime(n); } int main(){ int i, q; scanf("%d", &q); for(i=0;in) puts("No"); else puts("Yes"); } } return 0; }