#![allow(non_snake_case, unused_imports)] use proconio::{fastout, input, marker::*}; #[fastout] fn main() { input! { Q: usize, A: [usize; Q], } for mut a in A { let mut cnt = 0; for i in 2.. { if i * i * i > a { break; } if a % i == 0 { while a % i == 0 { cnt += 1; a /= i; } break; } } for i in 2.. { if i * i > a { break; } if a % i == 0 { while a % i == 0 { cnt += 1; a /= i; } break; } } if (cnt == 2 && miller_rabin_primality_test(a)) || cnt == 3 { println!("Yes"); } else { println!("No"); } } } pub fn miller_rabin_primality_test(n: usize) -> bool { fn pow(a: usize, b: usize, m: usize) -> usize { let (mut a, mut b, m) = (a as u128, b as u128, m as u128); let mut ret = 1; a %= m; while b > 0 { if b & 1 == 1 { ret = (ret * a) % m; } a = (a * a) % m; b >>= 1; } ret as usize } if n == 0 || n == 1 { false } else if n == 2 { true } else if n % 2 == 0 { false } else { const A: [usize; 7] = [2, 325, 9375, 28178, 450775, 9780504, 1795265022]; let mut s = 0; let mut d = n - 1; while d % 2 == 0 { s += 1; d >>= 1; } for a in A { if a % n == 0 { return true; } let mut x = pow(a, d, n); if x != 1 { for t in 0..s { if x == n - 1 { break; } x = pow(x, 2, n); if t == s - 1 { return false; } } } } true } }