Combination Table

combination_table は、二項係数や階乗を必要に応じて遅延構築する小さな補助 module です。

int.C(n, r) のように、型に対して method 風に呼び出せます。

import

import atcoder/extra/math/combination_table

使用例

import atcoder/extra/math/combination_tabledoAssert int.C(5, 2) == 10doAssert int.H(3, 2) == 6doAssert int.P(5, 2) == 20doAssert int.fact(5) == 120

API

C

T.C(n, r)

二項係数 n choose r を返します。範囲外では 0 を返します。

H

T.H(n, r)

重複組合せを返します。

P

T.P(n, r)

順列数を返します。

fact

T.fact(k)

k! を返します。

resetCombination

T.resetCombination()

内部 table を初期化します。

計算量

必要な値まで table を拡張します。