pub struct ModInt<T> {
pub value: T,
pub modulo: T,
}
Expand description
§Example
use competitive_hpp::prelude::*;
const MOD: usize = 7;
let mi0 = ModInt::new_with(0, MOD);
let mi1 = ModInt::new_with(1, MOD);
let mi2 = ModInt::new_with(2, MOD);
let mi11 = ModInt::new_with(11, MOD);
assert_eq!(4, ModInt::new(4));
assert_eq!(mi0 + mi11, ModInt::new_with(4, 7));
assert_eq!(mi1 + mi2, ModInt::new_with(3, 7));
Fields§
§value: T
§modulo: T
Trait Implementations§
Source§impl<T> AddAssign<T> for ModInt<T>where
T: PrimInt,
impl<T> AddAssign<T> for ModInt<T>where
T: PrimInt,
Source§fn add_assign(&mut self, rhs: T)
fn add_assign(&mut self, rhs: T)
Performs the
+=
operation. Read moreSource§impl<T> AddAssign for ModInt<T>where
T: PrimInt,
impl<T> AddAssign for ModInt<T>where
T: PrimInt,
Source§fn add_assign(&mut self, other: ModInt<T>)
fn add_assign(&mut self, other: ModInt<T>)
Performs the
+=
operation. Read moreSource§impl<T> ModIntTrait<T> for ModInt<T>where
T: PrimInt,
impl<T> ModIntTrait<T> for ModInt<T>where
T: PrimInt,
Source§impl<T> One for ModInt<T>where
T: PrimInt,
impl<T> One for ModInt<T>where
T: PrimInt,
Source§impl<T: Ord> Ord for ModInt<T>
impl<T: Ord> Ord for ModInt<T>
Source§impl<T> PartialOrd<ModInt<T>> for i16where
T: PrimInt,
impl<T> PartialOrd<ModInt<T>> for i16where
T: PrimInt,
Source§impl<T> PartialOrd<ModInt<T>> for i32where
T: PrimInt,
impl<T> PartialOrd<ModInt<T>> for i32where
T: PrimInt,
Source§impl<T> PartialOrd<ModInt<T>> for i64where
T: PrimInt,
impl<T> PartialOrd<ModInt<T>> for i64where
T: PrimInt,
Source§impl<T> PartialOrd<ModInt<T>> for i8where
T: PrimInt,
impl<T> PartialOrd<ModInt<T>> for i8where
T: PrimInt,
Source§impl<T> PartialOrd<ModInt<T>> for isizewhere
T: PrimInt,
impl<T> PartialOrd<ModInt<T>> for isizewhere
T: PrimInt,
Source§impl<T> PartialOrd<ModInt<T>> for u16where
T: PrimInt,
impl<T> PartialOrd<ModInt<T>> for u16where
T: PrimInt,
Source§impl<T> PartialOrd<ModInt<T>> for u32where
T: PrimInt,
impl<T> PartialOrd<ModInt<T>> for u32where
T: PrimInt,
Source§impl<T> PartialOrd<ModInt<T>> for u64where
T: PrimInt,
impl<T> PartialOrd<ModInt<T>> for u64where
T: PrimInt,
Source§impl<T> PartialOrd<ModInt<T>> for u8where
T: PrimInt,
impl<T> PartialOrd<ModInt<T>> for u8where
T: PrimInt,
Source§impl<T> PartialOrd<ModInt<T>> for usizewhere
T: PrimInt,
impl<T> PartialOrd<ModInt<T>> for usizewhere
T: PrimInt,
Source§impl<T> PartialOrd<T> for ModInt<T>where
T: PrimInt,
impl<T> PartialOrd<T> for ModInt<T>where
T: PrimInt,
Source§impl<T: PartialOrd> PartialOrd for ModInt<T>
impl<T: PartialOrd> PartialOrd for ModInt<T>
Source§impl<T> SubAssign<T> for ModInt<T>where
T: PrimInt,
impl<T> SubAssign<T> for ModInt<T>where
T: PrimInt,
Source§fn sub_assign(&mut self, rhs: T)
fn sub_assign(&mut self, rhs: T)
Performs the
-=
operation. Read moreSource§impl<T> SubAssign for ModInt<T>where
T: PrimInt,
impl<T> SubAssign for ModInt<T>where
T: PrimInt,
Source§fn sub_assign(&mut self, other: ModInt<T>)
fn sub_assign(&mut self, other: ModInt<T>)
Performs the
-=
operation. Read moreSource§impl<T> ToPrimitive for ModInt<T>where
T: PrimInt,
impl<T> ToPrimitive for ModInt<T>where
T: PrimInt,
Source§fn to_i8(&self) -> Option<i8>
fn to_i8(&self) -> Option<i8>
Converts the value of
self
to an i8
. If the value cannot be
represented by an i8
, then None
is returned.Source§fn to_i16(&self) -> Option<i16>
fn to_i16(&self) -> Option<i16>
Converts the value of
self
to an i16
. If the value cannot be
represented by an i16
, then None
is returned.Source§fn to_i32(&self) -> Option<i32>
fn to_i32(&self) -> Option<i32>
Converts the value of
self
to an i32
. If the value cannot be
represented by an i32
, then None
is returned.Source§fn to_i64(&self) -> Option<i64>
fn to_i64(&self) -> Option<i64>
Converts the value of
self
to an i64
. If the value cannot be
represented by an i64
, then None
is returned.Source§fn to_u8(&self) -> Option<u8>
fn to_u8(&self) -> Option<u8>
Converts the value of
self
to a u8
. If the value cannot be
represented by a u8
, then None
is returned.Source§fn to_u16(&self) -> Option<u16>
fn to_u16(&self) -> Option<u16>
Converts the value of
self
to a u16
. If the value cannot be
represented by a u16
, then None
is returned.Source§fn to_u32(&self) -> Option<u32>
fn to_u32(&self) -> Option<u32>
Converts the value of
self
to a u32
. If the value cannot be
represented by a u32
, then None
is returned.Source§fn to_u64(&self) -> Option<u64>
fn to_u64(&self) -> Option<u64>
Converts the value of
self
to a u64
. If the value cannot be
represented by a u64
, then None
is returned.Source§fn to_isize(&self) -> Option<isize>
fn to_isize(&self) -> Option<isize>
Converts the value of
self
to an isize
. If the value cannot be
represented by an isize
, then None
is returned.Source§fn to_usize(&self) -> Option<usize>
fn to_usize(&self) -> Option<usize>
Converts the value of
self
to a usize
. If the value cannot be
represented by a usize
, then None
is returned.Source§fn to_i128(&self) -> Option<i128>
fn to_i128(&self) -> Option<i128>
Converts the value of
self
to an i128
. If the value cannot be
represented by an i128
(i64
under the default implementation), then
None
is returned. Read moreSource§fn to_u128(&self) -> Option<u128>
fn to_u128(&self) -> Option<u128>
Converts the value of
self
to a u128
. If the value cannot be
represented by a u128
(u64
under the default implementation), then
None
is returned. Read moreimpl<T: Copy> Copy for ModInt<T>
impl<T: Eq> Eq for ModInt<T>
impl<T> StructuralPartialEq for ModInt<T>
Auto Trait Implementations§
impl<T> Freeze for ModInt<T>where
T: Freeze,
impl<T> RefUnwindSafe for ModInt<T>where
T: RefUnwindSafe,
impl<T> Send for ModInt<T>where
T: Send,
impl<T> Sync for ModInt<T>where
T: Sync,
impl<T> Unpin for ModInt<T>where
T: Unpin,
impl<T> UnwindSafe for ModInt<T>where
T: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more