結果

問題 No.1044 正直者大学
ユーザー tktk_snsntktk_snsn
提出日時 2020-12-25 15:38:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 67 ms / 2,000 ms
コード長 1,411 bytes
コンパイル時間 2,024 ms
コンパイル使用メモリ 81,504 KB
実行使用メモリ 68,444 KB
最終ジャッジ日時 2023-10-22 07:18:49
合計ジャッジ時間 2,827 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
51,908 KB
testcase_01 AC 39 ms
51,908 KB
testcase_02 AC 44 ms
58,308 KB
testcase_03 AC 39 ms
51,900 KB
testcase_04 AC 39 ms
51,900 KB
testcase_05 AC 54 ms
60,948 KB
testcase_06 AC 67 ms
67,920 KB
testcase_07 AC 39 ms
51,932 KB
testcase_08 AC 39 ms
51,916 KB
testcase_09 AC 40 ms
51,916 KB
testcase_10 AC 39 ms
51,924 KB
testcase_11 AC 38 ms
51,920 KB
testcase_12 AC 59 ms
65,264 KB
testcase_13 AC 60 ms
64,832 KB
testcase_14 AC 59 ms
64,860 KB
testcase_15 AC 64 ms
67,380 KB
testcase_16 AC 61 ms
65,272 KB
testcase_17 AC 65 ms
68,444 KB
testcase_18 AC 65 ms
68,180 KB
testcase_19 AC 56 ms
63,440 KB
testcase_20 AC 53 ms
62,632 KB
testcase_21 AC 55 ms
63,040 KB
testcase_22 AC 47 ms
58,880 KB
testcase_23 AC 52 ms
60,312 KB
testcase_24 AC 49 ms
59,488 KB
testcase_25 AC 48 ms
59,368 KB
testcase_26 AC 50 ms
60,028 KB
testcase_27 AC 38 ms
51,920 KB
testcase_28 AC 38 ms
51,928 KB
testcase_29 AC 39 ms
52,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class Combination:
    """
    SIZEが10**6程度以下の二項係数を何回も呼び出したいときに使う
    使い方:
    comb = Combination(SIZE, MOD)
    comb(10, 3) => 120
    """

    def __init__(self, N, MOD=10 ** 9 + 7):
        self.MOD = MOD
        self.__make_factorial_list(N)

    def __call__(self, n, k):
        if k < 0 or k > n:
            return 0
        res = self.fact[n] * self.inv[k] % self.MOD
        res = res * self.inv[n - k] % self.MOD
        return res

    def nPk(self, n, k):
        if k < 0 or k > n:
            return 0
        return self.fact[n] * self.inv[n - k] % self.MOD

    def __make_factorial_list(self, N):
        self.fact = [1] * (N + 1)
        self.inv = [1] * (N + 1)
        MOD = self.MOD
        for i in range(1, N + 1):
            self.fact[i] = (self.fact[i - 1] * i) % MOD
        self.inv[N] = pow(self.fact[N], MOD - 2, MOD)
        for i in range(N, 0, -1):
            self.inv[i - 1] = (self.inv[i] * i) % MOD
        return


mod = 10 ** 9 + 7
N, M, K = map(int, input().split())
comb = Combination(N + M + 100, mod)

ans = 0
for i in range(1, N + 1):  # Mをiこのグループに分ける
    pair = N + M - 2 * i
    if pair < K:
        break
    group = comb(M - 1, i - 1)
    insert = comb(N, i)
    ans += group * insert % mod
    ans %= mod

ans *= comb.fact[N - 1]
ans %= mod
ans *= comb.fact[M]
ans %= mod

print(ans)
0