library_checker/number_theory/discrete_logarithm_mod.rs
1use competitive::math::discrete_logarithm;
2use competitive::prelude::*;
3
4#[verify::library_checker("discrete_logarithm_mod")]
5pub fn discrete_logarithm_mod(reader: impl Read, writer: impl Write) {
6 prepare_io!(reader, writer);
7 sc!(t, query: [(u64, u64, u64); iter t]);
8 for (x, y, m) in query {
9 let ans = discrete_logarithm(x, y, m).map(|k| k as i64).unwrap_or(-1);
10 pp!(ans);
11 }
12}