algo — C++23 日本語リファレンス GitHub

static_modint

クラス · modint (static_modint / dynamic_modint)

template <int m>
requires (m >= 1)
struct static_modint : internal::static_modint_base, internal::modint_common<static_modint<m>>;

概要

コンパイル時に法を固定する modint

計算量

構築・破棄

名前 説明 計算量
(constructor) (1) 0を構築する
(2) 符号付き整数を法mで正規化して構築する
(3) 符号なし整数を法mで正規化して構築する
$O(1)$

メンバ関数

名前 説明 計算量
val 保持している標準剰余を返す
(基底 internal::modint_common から継承)
$O(1)$
pow n乗を返す
(基底 internal::modint_common から継承)
$O(\log n)$
inv 乗法逆元を返す
(基底 internal::modint_common から継承)
法を $m$ として $O(\log m)$

演算子

名前 説明 計算量
operator++ (1) 1を加算する
(2) 1を加算する前の値を返す
(基底 internal::modint_common から継承)
$O(1)$
operator-- (1) 1を減算する
(2) 1を減算する前の値を返す
(基底 internal::modint_common から継承)
$O(1)$
operator+= rhsを加算する
(基底 internal::modint_common から継承)
$O(1)$
operator-= rhsを減算する
(基底 internal::modint_common から継承)
$O(1)$
operator*= rhsを乗算する
(基底 internal::modint_common から継承)
$O(1)$
operator/= rhsで除算する
(基底 internal::modint_common から継承)
素数法では法を $m$ として $O(\log m)$、動的法では $O(\log m)$
operator+ (1) 自身の値を返す
(2) 和を返す
(基底 internal::modint_common から継承)
$O(1)$
operator- (1) 加法逆元を返す
(2) 差を返す
(基底 internal::modint_common から継承)
$O(1)$
operator* 積を返す
(基底 internal::modint_common から継承)
$O(1)$
operator/ 商を返す
(基底 internal::modint_common から継承)
法を $m$ として $O(\log m)$
operator== 等しいか返す
(基底 internal::modint_common から継承)
$O(1)$
operator!= 異なるか返す
(基底 internal::modint_common から継承)
$O(1)$
operator>> 整数を入力して法で正規化する
(基底 internal::modint_common から継承)
$O(1)$
operator<< 標準剰余を出力する
(基底 internal::modint_common から継承)
$O(1)$

静的メンバ関数

名前 説明 計算量
umod 法を unsigned int で返す $O(1)$
is_prime_mod 法が素数かをコンパイル時に返す コンパイル時定数で実行時計算量はない
mul aとbを乗算して法mで剰余を取る $O(1)$
mod 法を返す $O(1)$
raw 正規化済みの値vから検査なしで構築する $O(1)$

メンバ型

名前 説明 計算量
mint この型自身 型エイリアスで実行時計算量はない
base 四則演算を実装する基底型 型エイリアスで実行時計算量はない
_v 基底型が保持する正規化済みの値 $O(1)$ で参照可能

メンバの詳細

(constructor)

// (1)
constexpr static_modint() = default;

// (2)
template <std::integral T>
constexpr static_modint(T v);

// (3)
template <std::unsigned_integral T>
constexpr static_modint(T v);

(1) 0を構築する

(2) 符号付き整数を法mで正規化して構築する

(3) 符号なし整数を法mで正規化して構築する

operator++

// (1)
constexpr mint &operator++();

// (2)
constexpr mint operator++(int);

(基底 internal::modint_common から継承)

(1) 1を加算する

(2) 1を加算する前の値を返す

operator–

// (1)
constexpr mint &operator--();

// (2)
constexpr mint operator--(int);

(基底 internal::modint_common から継承)

(1) 1を減算する

(2) 1を減算する前の値を返す

operator+

// (1)
constexpr mint operator+() const;

// (2)
friend constexpr mint operator+(const mint &lhs, const mint &rhs);

(基底 internal::modint_common から継承)

(1) 自身の値を返す

(2) 和を返す

operator-

// (1)
constexpr mint operator-() const;

// (2)
friend constexpr mint operator-(const mint &lhs, const mint &rhs);

(基底 internal::modint_common から継承)

(1) 加法逆元を返す

(2) 差を返す

関連項目