Skip to main content

library_checker/number_theory/
primality_test.rs

1#[doc(no_inline)]
2pub use competitive::math::miller_rabin;
3use competitive::prelude::*;
4
5#[verify::library_checker("primality_test")]
6pub fn primality_test(reader: impl Read, mut writer: impl Write) {
7    let s = read_all_unchecked(reader);
8    let mut scanner = Scanner::new(&s);
9    scan!(scanner, q);
10    for _ in 0..q {
11        scan!(scanner, n: u64);
12        let ans = if miller_rabin(n) { "Yes" } else { "No" };
13        writeln!(writer, "{}", ans).ok();
14    }
15}