結果

問題 No.1044 正直者大学
ユーザー yuly3yuly3
提出日時 2020-05-02 18:44:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 120 ms / 2,000 ms
コード長 1,437 bytes
コンパイル時間 282 ms
コンパイル使用メモリ 87,156 KB
実行使用メモリ 81,768 KB
最終ジャッジ日時 2023-08-29 22:00:27
合計ジャッジ時間 5,545 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
80,576 KB
testcase_01 AC 94 ms
80,648 KB
testcase_02 AC 94 ms
80,624 KB
testcase_03 AC 96 ms
80,656 KB
testcase_04 AC 91 ms
80,588 KB
testcase_05 AC 95 ms
80,792 KB
testcase_06 AC 118 ms
81,332 KB
testcase_07 AC 94 ms
80,648 KB
testcase_08 AC 92 ms
80,648 KB
testcase_09 AC 94 ms
80,508 KB
testcase_10 AC 91 ms
80,540 KB
testcase_11 AC 90 ms
80,620 KB
testcase_12 AC 102 ms
80,948 KB
testcase_13 AC 116 ms
81,556 KB
testcase_14 AC 104 ms
81,036 KB
testcase_15 AC 104 ms
80,752 KB
testcase_16 AC 116 ms
81,652 KB
testcase_17 AC 118 ms
81,588 KB
testcase_18 AC 120 ms
81,768 KB
testcase_19 AC 106 ms
81,048 KB
testcase_20 AC 100 ms
81,088 KB
testcase_21 AC 106 ms
80,872 KB
testcase_22 AC 93 ms
80,772 KB
testcase_23 AC 94 ms
80,648 KB
testcase_24 AC 94 ms
80,680 KB
testcase_25 AC 96 ms
80,684 KB
testcase_26 AC 93 ms
80,720 KB
testcase_27 AC 94 ms
80,688 KB
testcase_28 AC 91 ms
80,500 KB
testcase_29 AC 94 ms
80,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


class Combination:
    def __init__(self, n: int, mod: int):
        self.mod = mod
        self.fact = [0] * (n + 1)
        self.factinv = [0] * (n + 1)
        self.inv = [0] * (n + 1)
        
        self.fact[0] = self.fact[1] = 1
        self.factinv[0] = self.factinv[1] = 1
        self.inv[1] = 1
        for i in range(2, n + 1):
            self.fact[i] = (self.fact[i - 1] * i) % mod
            self.inv[i] = (-self.inv[mod % i] * (mod // i)) % mod
            self.factinv[i] = (self.factinv[i - 1] * self.inv[i]) % mod
    
    def ncr(self, n: int, r: int):
        if r < 0 or n < r:
            return 0
        r = min(r, n - r)
        return self.fact[n] * self.factinv[r] % self.mod * self.factinv[n - r] % self.mod
    
    def nhr(self, n: int, r: int):
        return self.ncr(n + r - 1, r)
    
    def npr(self, n: int, r: int):
        if r < 0 or n < r:
            return 0
        return self.fact[n] * self.factinv[n - r] % self.mod


def solve():
    N, M, K = map(int, rl().split())
    MOD = 10 ** 9 + 7
    com = Combination(200010, MOD)
    
    ans = 0
    for i in range(1, N + 1):
        if N - i + M - i < K:
            continue
        ans = (ans + com.ncr(N, i) * com.nhr(i, M - i)) % MOD
    
    ans = ans * com.fact[N - 1] % MOD
    ans = ans * com.fact[M] % MOD
    print(ans)


if __name__ == '__main__':
    solve()
0