#include #include #include typedef unsigned __int128 uint128_t; uint64_t modpow64(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; } const uint64_t as64[] = {2, 325, 9375, 28178, 450775, 9780504, 1795265022}; int is_prime64(uint64_t n){ int i, j, r; uint64_t d; if(n <= 1) return 0; if(n <= 3) return 1; if(!(n & 1)) return 0; r = __builtin_ctzll(n-1); d = (n-1) >> r; for(i=0;i<7;i++){ uint64_t a = as64[i]; uint64_t t = modpow64(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; } uint64_t gcd64(uint64_t x, uint64_t y){ if(x == 0 || y == 0) return x^y; int bx = __builtin_ctzll(x); int by = __builtin_ctzll(y); int k = (bx < by) ? bx : by; x >>= bx; y >>= by; while(x!=y){ if(x < y){ y -= x; y >>= __builtin_ctzll(y); } else { x -= y; x >>= __builtin_ctzll(x); } } return x << k; } int is_power64(uint64_t n, uint64_t p){ int i; uint64_t a[41]; uint64_t x; a[0] = p; for(i=0; a[i] <= n; i++){ a[i+1] = a[i] * a[i]; } x = a[--i]; if(x == n) return 1; for(--i; i>=0;--i){ uint64_t y = x * a[i]; if(y == n) return 1; else if(y < n) x = y; } return 0; } uint64_t is_primepower64(uint64_t n){ uint64_t i; if(n <= 1) return 0; if(!(n&(n-1))) return 2; if(!(n&1)) return 0; for(i=0;i<7;i++){ uint64_t x = as64[i] % n; uint64_t in = modpow64(x, n, n); uint64_t inmi = in >= x ? in - x : in + n - x; uint64_t p = gcd64(inmi, n); if(p == 1) return 0; if(is_prime64(p)){ return is_power64(n, p); } n = p; } return 0; } int main(){ int i, q; scanf("%d", &q); for(i=0;i=n) puts("No"); else puts("Yes"); } } return 0; }