Struct StaticModInt

Source
pub struct StaticModInt<M> { /* private fields */ }
Expand description

Represents $\mathbb{Z}/m\mathbb{Z}$ where $m$ is a constant value.

Corresponds to atcoder::static_modint in the original ACL.

§Example

use ac_library::ModInt1000000007 as Mint;
use proconio::{input, source::once::OnceSource};

input! {
    from OnceSource::from("1000000006 2\n"),
    a: Mint,
    b: Mint,
}

println!("{}", a + b); // `1`

Implementations§

Source§

impl<M: Modulus> StaticModInt<M>

Source

pub fn modulus() -> u32

Returns the modulus, which is <M as Modulus>::VALUE.

Corresponds to atcoder::static_modint::mod in the original ACL.

§Example
use ac_library::ModInt1000000007 as Mint;

assert_eq!(1_000_000_007, Mint::modulus());
Source

pub fn new<T: RemEuclidU32>(val: T) -> Self

Creates a new StaticModInt.

Takes any primitive integer.

Corresponds to the constructor of atcoder::static_modint in the original ACL.

Source

pub fn raw(val: u32) -> Self

Constructs a StaticModInt from a val < Self::modulus() without checking it.

Corresponds to atcoder::static_modint::raw in the original ACL.

§Constraints
  • val is less than Self::modulus()

See ModIntBase::raw for more more details.

Source

pub fn val(self) -> u32

Retruns the representative.

Corresponds to atcoder::static_modint::val in the original ACL.

Source

pub fn pow(self, n: u64) -> Self

Returns self to the power of n.

Corresponds to atcoder::static_modint::pow in the original ACL.

Source

pub fn inv(self) -> Self

Retruns the multiplicative inverse of self.

Corresponds to atcoder::static_modint::inv in the original ACL.

§Panics

Panics if the multiplicative inverse does not exist.

Trait Implementations§

Source§

impl<M: Modulus> Add<&StaticModInt<M>> for &StaticModInt<M>

Source§

type Output = StaticModInt<M>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &StaticModInt<M>) -> StaticModInt<M>

Performs the + operation. Read more
Source§

impl<M: Modulus> Add<&StaticModInt<M>> for StaticModInt<M>

Source§

type Output = StaticModInt<M>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &StaticModInt<M>) -> StaticModInt<M>

Performs the + operation. Read more
Source§

impl<M: Modulus> Add<StaticModInt<M>> for &StaticModInt<M>

Source§

type Output = StaticModInt<M>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: StaticModInt<M>) -> StaticModInt<M>

Performs the + operation. Read more
Source§

impl<M: Modulus, T: RemEuclidU32> Add<T> for StaticModInt<M>

Source§

type Output = StaticModInt<M>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: T) -> StaticModInt<M>

Performs the + operation. Read more
Source§

impl<M: Modulus> Add for StaticModInt<M>

Source§

type Output = StaticModInt<M>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: StaticModInt<M>) -> StaticModInt<M>

Performs the + operation. Read more
Source§

impl<M: Modulus> AddAssign<&StaticModInt<M>> for StaticModInt<M>

Source§

fn add_assign(&mut self, rhs: &StaticModInt<M>)

Performs the += operation. Read more
Source§

impl<M: Modulus, T: RemEuclidU32> AddAssign<T> for StaticModInt<M>

Source§

fn add_assign(&mut self, rhs: T)

Performs the += operation. Read more
Source§

impl<M: Modulus> AddAssign for StaticModInt<M>

Source§

fn add_assign(&mut self, rhs: StaticModInt<M>)

Performs the += operation. Read more
Source§

impl<M: Clone> Clone for StaticModInt<M>

Source§

fn clone(&self) -> StaticModInt<M>

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<M: Modulus> Debug for StaticModInt<M>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<M: Modulus> Default for StaticModInt<M>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<M: Modulus> Display for StaticModInt<M>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<M: Modulus> Div<&StaticModInt<M>> for &StaticModInt<M>

Source§

type Output = StaticModInt<M>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &StaticModInt<M>) -> StaticModInt<M>

Performs the / operation. Read more
Source§

impl<M: Modulus> Div<&StaticModInt<M>> for StaticModInt<M>

Source§

type Output = StaticModInt<M>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &StaticModInt<M>) -> StaticModInt<M>

Performs the / operation. Read more
Source§

impl<M: Modulus> Div<StaticModInt<M>> for &StaticModInt<M>

Source§

type Output = StaticModInt<M>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: StaticModInt<M>) -> StaticModInt<M>

Performs the / operation. Read more
Source§

impl<M: Modulus, T: RemEuclidU32> Div<T> for StaticModInt<M>

Source§

type Output = StaticModInt<M>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: T) -> StaticModInt<M>

Performs the / operation. Read more
Source§

impl<M: Modulus> Div for StaticModInt<M>

Source§

type Output = StaticModInt<M>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: StaticModInt<M>) -> StaticModInt<M>

Performs the / operation. Read more
Source§

impl<M: Modulus> DivAssign<&StaticModInt<M>> for StaticModInt<M>

Source§

fn div_assign(&mut self, rhs: &StaticModInt<M>)

Performs the /= operation. Read more
Source§

impl<M: Modulus, T: RemEuclidU32> DivAssign<T> for StaticModInt<M>

Source§

fn div_assign(&mut self, rhs: T)

Performs the /= operation. Read more
Source§

impl<M: Modulus> DivAssign for StaticModInt<M>

Source§

fn div_assign(&mut self, rhs: StaticModInt<M>)

Performs the /= operation. Read more
Source§

impl<M: Modulus, V: RemEuclidU32> From<V> for StaticModInt<M>

Source§

fn from(from: V) -> Self

Converts to this type from the input type.
Source§

impl<M: Modulus> FromStr for StaticModInt<M>

Source§

type Err = Infallible

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Infallible>

Parses a string s to return a value of this type. Read more
Source§

impl<M: Modulus> Hash for StaticModInt<M>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<M: Modulus> ModIntBase for StaticModInt<M>

These methods are implemented for the struct. You don’t need to use ModIntBase to call methods of StaticModInt.

Source§

fn modulus() -> u32

Returns the modulus. Read more
Source§

fn raw(val: u32) -> Self

Constructs a Self from a val < Self::modulus() without checking it. Read more
Source§

fn val(self) -> u32

Retruns the representative. Read more
Source§

fn inv(self) -> Self

Retruns the multiplicative inverse of self. Read more
Source§

fn new<T: RemEuclidU32>(val: T) -> Self

Creates a new Self. Read more
Source§

fn pow(self, n: u64) -> Self

Returns self to the power of n. Read more
Source§

impl<M: Modulus> Mul<&StaticModInt<M>> for &StaticModInt<M>

Source§

type Output = StaticModInt<M>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &StaticModInt<M>) -> StaticModInt<M>

Performs the * operation. Read more
Source§

impl<M: Modulus> Mul<&StaticModInt<M>> for StaticModInt<M>

Source§

type Output = StaticModInt<M>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &StaticModInt<M>) -> StaticModInt<M>

Performs the * operation. Read more
Source§

impl<M: Modulus> Mul<StaticModInt<M>> for &StaticModInt<M>

Source§

type Output = StaticModInt<M>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: StaticModInt<M>) -> StaticModInt<M>

Performs the * operation. Read more
Source§

impl<M: Modulus, T: RemEuclidU32> Mul<T> for StaticModInt<M>

Source§

type Output = StaticModInt<M>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: T) -> StaticModInt<M>

Performs the * operation. Read more
Source§

impl<M: Modulus> Mul for StaticModInt<M>

Source§

type Output = StaticModInt<M>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: StaticModInt<M>) -> StaticModInt<M>

Performs the * operation. Read more
Source§

impl<M: Modulus> MulAssign<&StaticModInt<M>> for StaticModInt<M>

Source§

fn mul_assign(&mut self, rhs: &StaticModInt<M>)

Performs the *= operation. Read more
Source§

impl<M: Modulus, T: RemEuclidU32> MulAssign<T> for StaticModInt<M>

Source§

fn mul_assign(&mut self, rhs: T)

Performs the *= operation. Read more
Source§

impl<M: Modulus> MulAssign for StaticModInt<M>

Source§

fn mul_assign(&mut self, rhs: StaticModInt<M>)

Performs the *= operation. Read more
Source§

impl<M: Modulus> Neg for &StaticModInt<M>

Source§

type Output = StaticModInt<M>

The resulting type after applying the - operator.
Source§

fn neg(self) -> StaticModInt<M>

Performs the unary - operation. Read more
Source§

impl<M: Modulus> Neg for StaticModInt<M>

Source§

type Output = StaticModInt<M>

The resulting type after applying the - operator.
Source§

fn neg(self) -> StaticModInt<M>

Performs the unary - operation. Read more
Source§

impl<M: PartialEq> PartialEq for StaticModInt<M>

Source§

fn eq(&self, other: &StaticModInt<M>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, M: Modulus> Product<&'a StaticModInt<M>> for StaticModInt<M>

Source§

fn product<S>(iter: S) -> Self
where S: Iterator<Item = &'a Self>,

Takes an iterator and generates Self from the elements by multiplying the items.
Source§

impl<M: Modulus> Product for StaticModInt<M>

Source§

fn product<S>(iter: S) -> Self
where S: Iterator<Item = Self>,

Takes an iterator and generates Self from the elements by multiplying the items.
Source§

impl<M: Modulus> Sub<&StaticModInt<M>> for &StaticModInt<M>

Source§

type Output = StaticModInt<M>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &StaticModInt<M>) -> StaticModInt<M>

Performs the - operation. Read more
Source§

impl<M: Modulus> Sub<&StaticModInt<M>> for StaticModInt<M>

Source§

type Output = StaticModInt<M>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &StaticModInt<M>) -> StaticModInt<M>

Performs the - operation. Read more
Source§

impl<M: Modulus> Sub<StaticModInt<M>> for &StaticModInt<M>

Source§

type Output = StaticModInt<M>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: StaticModInt<M>) -> StaticModInt<M>

Performs the - operation. Read more
Source§

impl<M: Modulus, T: RemEuclidU32> Sub<T> for StaticModInt<M>

Source§

type Output = StaticModInt<M>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: T) -> StaticModInt<M>

Performs the - operation. Read more
Source§

impl<M: Modulus> Sub for StaticModInt<M>

Source§

type Output = StaticModInt<M>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: StaticModInt<M>) -> StaticModInt<M>

Performs the - operation. Read more
Source§

impl<M: Modulus> SubAssign<&StaticModInt<M>> for StaticModInt<M>

Source§

fn sub_assign(&mut self, rhs: &StaticModInt<M>)

Performs the -= operation. Read more
Source§

impl<M: Modulus, T: RemEuclidU32> SubAssign<T> for StaticModInt<M>

Source§

fn sub_assign(&mut self, rhs: T)

Performs the -= operation. Read more
Source§

impl<M: Modulus> SubAssign for StaticModInt<M>

Source§

fn sub_assign(&mut self, rhs: StaticModInt<M>)

Performs the -= operation. Read more
Source§

impl<'a, M: Modulus> Sum<&'a StaticModInt<M>> for StaticModInt<M>

Source§

fn sum<S>(iter: S) -> Self
where S: Iterator<Item = &'a Self>,

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl<M: Modulus> Sum for StaticModInt<M>

Source§

fn sum<S>(iter: S) -> Self
where S: Iterator<Item = Self>,

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl<M: Copy> Copy for StaticModInt<M>

Source§

impl<M: Eq> Eq for StaticModInt<M>

Source§

impl<M> StructuralPartialEq for StaticModInt<M>

Auto Trait Implementations§

§

impl<M> Freeze for StaticModInt<M>

§

impl<M> RefUnwindSafe for StaticModInt<M>

§

impl<M> Send for StaticModInt<M>

§

impl<M> Sync for StaticModInt<M>

§

impl<M> Unpin for StaticModInt<M>

§

impl<M> UnwindSafe for StaticModInt<M>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.