ac-library-rs
ac-library-rs copied to clipboard
Corner cases of "modint" when mod = 1
https://github.com/rust-lang-ja/ac-library-rs/blob/d2b35ac542160c963d49d180194e77fc6a03fd7d/src/modint.rs#L676 https://github.com/rust-lang-ja/ac-library-rs/blob/d2b35ac542160c963d49d180194e77fc6a03fd7d/src/modint.rs#L1046 https://github.com/rust-lang-ja/ac-library-rs/blob/d2b35ac542160c963d49d180194e77fc6a03fd7d/src/modint.rs#L1048
The identity of multiplication should be Self::new(1)(not raw but new), because of following (corner) cases:
use ac_library_rs::ModInt;
ModInt::set_modulus(1); // !!
let x: ModInt = std::iter::empty::<ModInt>().product();
assert_eq!(x.val(), 0);
let y = ModInt::new(123).pow(0);
assert_eq!(y.val(), 0);
Note that the original ACL allows to use modint::set_mod(1).