struct
AtCoder::DynamicModInt
- AtCoder::DynamicModInt
- Struct
- Value
- Object
Overview
Implements atcoder::dynamic_modint / atcoder::modint.
A ModInt whose modulus is set at runtime with .set_mod.
The default modulus is 998244353, as in ACL.
Multiplication is done with Barrett reduction.
alias Mint = AtCoder::DynamicModInt
Mint.set_mod(11)
Mint.new(3) // Mint.new(7) # => 2
Defined in:
mod_int.crConstructors
Class Method Summary
-
.combination(n, k)
Returns the binomial coefficient
n! / (k! (n - k)!). - .factorial(n)
-
.mod : Int64
Implements atcoder::modint.mod().
-
.permutation(n, k)
Returns the number of k-permutations of n,
n! / (n - k)!. -
.raw(value : Int)
Implements atcoder::modint.raw(x).
-
.repeated_combination(n, k)
Returns the number of k-combinations of n with repetitions,
.combination(n + k - 1, k). -
.set_mod(mod)
Implements atcoder::modint.set_mod(m).
- .zero
Instance Method Summary
- #*(value : self)
- #*(value)
- #**(value)
- #+(value : self)
- #+(value)
- #+
- #-(value : self)
- #-(value)
- #-
- #/(value : self)
- #/(value)
- #//(value)
- #<(value)
- #<<(value)
- #<=(value)
- #==(other : self)
-
#==(other)
Returns
trueif this struct is equal to other. - #>(value)
- #>=(value)
- #abs
- #clone
-
#inspect(io : IO)
Appends this struct's name and instance variables names and values to the given IO.
-
#inv
Implements atcoder::modint.inv().
- #pow(value)
- #pred
- #sqrt
- #succ
- #to_i64
-
#to_s(io : IO)
Same as
#inspect(io). - #val
- #value : Int64
- #zero?
Constructor Detail
Class Method Detail
Returns the binomial coefficient n! / (k! (n - k)!).
Returns 0 if k < 0 or k > n. Raises ArgumentError if n < 0.
Returns the number of k-permutations of n, n! / (n - k)!.
Returns 0 if k < 0 or k > n. Raises ArgumentError if n < 0.
Implements atcoder::modint.raw(x).
Constructs a ModInt from value without taking the modulo.
value must be in 0...mod.
Returns the number of k-combinations of n with repetitions, .combination(n + k - 1, k).
Returns 0 if k < 0, and 1 if n == 0 and k == 0. Raises ArgumentError if n < 0.
Implements atcoder::modint.set_mod(m).
Raises ArgumentError unless 1 <= mod <= Int32::MAX.
The cache of .factorial is cleared.
Instance Method Detail
Returns true if this struct is equal to other.
Both structs' instance vars are compared to each other. Thus, two structs are considered equal if each of their instance variables are equal. Subclasses should override this method to provide specific equality semantics.
struct Point
def initialize(@x : Int32, @y : Int32)
end
end
p1 = Point.new 1, 2
p2 = Point.new 1, 2
p3 = Point.new 3, 4
p1 == p2 # => true
p1 == p3 # => false
Appends this struct's name and instance variables names and values to the given IO.
struct Point
def initialize(@x : Int32, @y : Int32)
end
end
p1 = Point.new 1, 2
p1.to_s # "Point(@x=1, @y=2)"
p1.inspect # "Point(@x=1, @y=2)"
Implements atcoder::modint.inv().
Raises ArgumentError if the value and the modulus are not coprime.