ModInt

value class ModInt(source)

自動で剰余を取る整数クラス

デフォルトの法は 998244353 で、ModInt.mod に代入することで変えられる

初期化の例

val x = ModInt.new(1_000_000_000)
val y = ModInt.raw(1) // 値が mod より小さい場合は raw の方が速い
val z = 1.m // new が呼ばれる

Parameters

x

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
val x: Int

Functions

Link copied to clipboard
operator fun div(other: Int): ModInt
operator fun div(other: Long): ModInt
operator fun div(other: ModInt): ModInt
operator fun Int.div(other: ModInt): ModInt
operator fun Long.div(other: ModInt): ModInt
Link copied to clipboard
fun inv(): ModInt

逆元

Link copied to clipboard
operator fun minus(other: Int): ModInt
operator fun minus(other: Long): ModInt
operator fun minus(other: ModInt): ModInt
operator fun Int.minus(other: ModInt): ModInt
operator fun Long.minus(other: ModInt): ModInt
Link copied to clipboard
operator fun plus(other: Int): ModInt
operator fun plus(other: Long): ModInt
operator fun plus(other: ModInt): ModInt
operator fun Int.plus(other: ModInt): ModInt
operator fun Long.plus(other: ModInt): ModInt
Link copied to clipboard
fun pow(n: Int): ModInt
fun pow(n: Long): ModInt

負の数にも対応した累乗

fun pow(n: UInt): ModInt
fun pow(n: ULong): ModInt

累乗

Link copied to clipboard
operator fun times(other: Int): ModInt
operator fun times(other: Long): ModInt
operator fun times(other: ModInt): ModInt
operator fun Int.times(other: ModInt): ModInt
operator fun Long.times(other: ModInt): ModInt
Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
operator fun unaryMinus(): ModInt
Link copied to clipboard
operator fun unaryPlus(): ModInt