library_checker/number_theory/sqrt_mod.rs
1use competitive::num::mint_basic::DynMIntU32;
2use competitive::prelude::*;
3
4#[verify::library_checker("sqrt_mod")]
5pub fn sqrt_mod(reader: impl Read, writer: impl Write) {
6 prepare_io!(reader, writer);
7 sc!(q, yp: [(u32, u32); iter q]);
8 for (y, p) in yp {
9 DynMIntU32::set_mod(p);
10 if let Some(x) = DynMIntU32::from(y).sqrt() {
11 pp!(x);
12 } else {
13 pp!("-1");
14 }
15 }
16}