pub struct ModInt<const MOD: i64> { /* private fields */ }Expand description
コンパイル時定数 MOD を法とする剰余整数です。
構築時に値を剰余で正規化し、保持値は常に 0 <= value < MOD です。MOD は正である必要が
あります。pow は非負整数の指数に使います。inv と / は MOD が素数で、対象の値が
法 MOD で 0 でない場合にのみ数学的な乗法逆元として機能します。
加算・減算・乗算・累乗の途中計算は i64 で行うため、中間値が i64 に収まる MOD を
選んでください。乗算については、少なくとも (MOD - 1) * (MOD - 1) が i64::MAX 以下に
なる法であることを確認してください。
§Panics
MOD <= 0 の場合は構築時に panic します。
§Examples
use atcoder::math::mod_int::Mod998;
let value = Mod998::new(-1);
assert_eq!(value.value(), 998_244_352);
assert_eq!((value + Mod998::new(2)).value(), 1);Implementations§
Source§impl<const MOD: i64> ModInt<MOD>
impl<const MOD: i64> ModInt<MOD>
Trait Implementations§
Source§impl<const MOD: i64> AddAssign for ModInt<MOD>
impl<const MOD: i64> AddAssign for ModInt<MOD>
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+= operation. Read moreimpl<const MOD: i64> Copy for ModInt<MOD>
Source§impl<const MOD: i64> DivAssign for ModInt<MOD>
impl<const MOD: i64> DivAssign for ModInt<MOD>
Source§fn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
Performs the
/= operation. Read moreimpl<const MOD: i64> Eq for ModInt<MOD>
Source§impl<const MOD: i64> MulAssign for ModInt<MOD>
impl<const MOD: i64> MulAssign for ModInt<MOD>
Source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
Performs the
*= operation. Read moreSource§impl<const MOD: i64> Ord for ModInt<MOD>
impl<const MOD: i64> Ord for ModInt<MOD>
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<const MOD: i64> PartialOrd for ModInt<MOD>
impl<const MOD: i64> PartialOrd for ModInt<MOD>
impl<const MOD: i64> StructuralPartialEq for ModInt<MOD>
Auto Trait Implementations§
impl<const MOD: i64> Freeze for ModInt<MOD>
impl<const MOD: i64> RefUnwindSafe for ModInt<MOD>
impl<const MOD: i64> Send for ModInt<MOD>
impl<const MOD: i64> Sync for ModInt<MOD>
impl<const MOD: i64> Unpin for ModInt<MOD>
impl<const MOD: i64> UnsafeUnpin for ModInt<MOD>
impl<const MOD: i64> UnwindSafe for ModInt<MOD>
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