fn main() { input!{ q: usize, a: [usize; q], } // 素数列挙して、素因数の候補を求める let eratos = erato(100_000); // 素因数分解して、肩が合計3つのものを見つける for &k in &a { let factors = factor(k, &eratos); if factors.len() == 3 { println!("Yes"); } else{ println!("No"); } } fn erato(x: usize) -> Vec { let mut ret = Vec::new(); let mut used = vec![true; x+1]; used[0] = false; used[1] = false; for i in 2..=x { if !used[i] { continue; } let mut multi = 2; ret.push(i); while i * multi <= x { used[i * multi] = false; multi += 1; } } ret } fn factor(x: usize, eratos: &Vec) -> Vec { let mut ret = Vec::new(); let mut i = 0; let mut tx = x; while i < eratos.len() && eratos[i]*eratos[i] <= x { while tx % eratos[i] == 0 { ret.push(eratos[i]); tx /= eratos[i]; } i += 1; } if tx != 1 { ret.push(tx); } ret } } // ---------- begin input macro ---------- #[macro_export] macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); input_inner!{iter, $($r)*} }; ($($r:tt)*) => { let s = { use std::io::Read; let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); s }; let mut iter = s.split_whitespace(); input_inner!{iter, $($r)*} }; } #[macro_export] macro_rules! input_inner { ($iter:expr) => {}; ($iter:expr, ) => {}; ($iter:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($iter, $t); input_inner!{$iter $($r)*} }; } #[macro_export] macro_rules! read_value { ($iter:expr, ( $($t:tt),* )) => { ( $(read_value!($iter, $t)),* ) }; ($iter:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($iter, $t)).collect::>() }; ($iter:expr, chars) => { read_value!($iter, String).chars().collect::>() }; ($iter:expr, bytes) => { read_value!($iter, String).bytes().collect::>() }; ($iter:expr, usize1) => { read_value!($iter, usize) - 1 }; ($iter:expr, $t:ty) => { $iter.next().unwrap().parse::<$t>().expect("Parse error") }; } // ---------- end input macro ---------- #[allow(unused)] use std::{ io::stderr, io::stdin, io::BufRead, io::Write, mem::swap, cmp::min, cmp::max, cmp::Reverse, collections::HashSet, collections::BTreeSet, collections::HashMap, collections::BTreeMap, collections::BinaryHeap, collections::VecDeque, };