pub struct ModInt<const M: i64>(/* private fields */);Implementations§
Source§impl<const M: i64> ModInt<M>
impl<const M: i64> ModInt<M>
Sourcepub fn val(self) -> i64
pub fn val(self) -> i64
ModInt に格納されている値を返します。
§Examples
use mod_int::ModInt1000000007;
assert_eq!(ModInt1000000007::new(123).val(), 123);Sourcepub fn modulo() -> i64
pub fn modulo() -> i64
法を返します。
§Examples
use mod_int::{ModInt1000000007, ModInt998244353};
assert_eq!(ModInt1000000007::modulo(), 1000000007);
assert_eq!(ModInt998244353::modulo(), 998244353);Sourcepub fn pow(self, exp: u32) -> Self
pub fn pow(self, exp: u32) -> Self
二分累乗法で x^exp % p を計算します。
§Examples
use mod_int::ModInt1000000007;
use std::iter::repeat;
let (x, exp, p) = (123, 100_u32, 1000000007);
let y = repeat(x).take(exp as usize).fold(1, |acc, x| acc * x % p);
assert_eq!(y, ModInt1000000007::new(x).pow(exp).val());Sourcepub fn inv(self) -> Self
pub fn inv(self) -> Self
x * y % p = 1 となる y を返します。
§Examples
use mod_int::ModInt1000000007;
let (x, p) = (2, ModInt1000000007::modulo());
let y = ModInt1000000007::new(x).inv().val();
assert_eq!(x * y % p, 1);ⓘ
use mod_int::ModInt1000000007;
ModInt1000000007::new(0).inv(); // panicⓘ
use mod_int::ModInt;
// 6 * n % 10 : 0, 6, 2, 8, 4, 0, 6, 2, 8, 4
ModInt::<10>::new(6).inv(); // panicTrait Implementations§
Source§impl<const M: i64, T: Into<ModInt<M>>> AddAssign<T> for ModInt<M>
impl<const M: i64, T: Into<ModInt<M>>> AddAssign<T> for ModInt<M>
Source§fn add_assign(&mut self, rhs: T)
fn add_assign(&mut self, rhs: T)
Performs the
+= operation. Read moreSource§impl<const M: i64, T: Into<ModInt<M>>> DivAssign<T> for ModInt<M>
impl<const M: i64, T: Into<ModInt<M>>> DivAssign<T> for ModInt<M>
Source§fn div_assign(&mut self, rhs: T)
fn div_assign(&mut self, rhs: T)
Performs the
/= operation. Read moreSource§impl<const M: i64, T: Into<ModInt<M>>> MulAssign<T> for ModInt<M>
impl<const M: i64, T: Into<ModInt<M>>> MulAssign<T> for ModInt<M>
Source§fn mul_assign(&mut self, rhs: T)
fn mul_assign(&mut self, rhs: T)
Performs the
*= operation. Read moreSource§impl<const M: i64, T: Into<ModInt<M>>> SubAssign<T> for ModInt<M>
impl<const M: i64, T: Into<ModInt<M>>> SubAssign<T> for ModInt<M>
Source§fn sub_assign(&mut self, rhs: T)
fn sub_assign(&mut self, rhs: T)
Performs the
-= operation. Read moreimpl<const M: i64> Copy for ModInt<M>
Auto Trait Implementations§
impl<const M: i64> Freeze for ModInt<M>
impl<const M: i64> RefUnwindSafe for ModInt<M>
impl<const M: i64> Send for ModInt<M>
impl<const M: i64> Sync for ModInt<M>
impl<const M: i64> Unpin for ModInt<M>
impl<const M: i64> UnwindSafe for ModInt<M>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more