結果

問題 No.1044 正直者大学
ユーザー buey_tbuey_t
提出日時 2023-03-28 18:11:05
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 2,753 bytes
コンパイル時間 237 ms
コンパイル使用メモリ 81,844 KB
実行使用メモリ 260,800 KB
最終ジャッジ日時 2023-10-20 11:48:01
合計ジャッジ時間 6,445 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 400 ms
260,520 KB
testcase_01 AC 400 ms
256,172 KB
testcase_02 AC 398 ms
256,172 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    from math import sqrt,sin,cos,tan,ceil,radians,floor,gcd,exp,log,log10,log2,factorial,fsum
    from heapq import heapify, heappop, heappush
    from bisect import bisect_left, bisect_right
    from copy import deepcopy
    import copy
    import random
    from collections import deque,Counter,defaultdict
    from itertools import permutations,combinations
    from decimal import Decimal,ROUND_HALF_UP
    #tmp = Decimal(mid).quantize(Decimal('0'), rounding=ROUND_HALF_UP)
    from functools import lru_cache, reduce
    #@lru_cache(maxsize=None)
    from operator import add,sub,mul,xor,and_,or_,itemgetter
    INF = 10**18
    mod1 = 10**9+7
    mod2 = 998244353
    
    #DecimalならPython
    #再帰ならPython!!!!!!!!!!!!!!!!!!!!!!!!!!
    
    #p = のところを変更すること。
    #limitationも必要なら変更
    def nCr(n, r, p):
        if (r < 0) or (n < r):
            return 0
        r = min(r, n - r)
        return fact[n] * factinv[r] * factinv[n-r] % p
    
    p = mod1
    limitation = 10 ** 6  # N は必要分だけ用意する
    fact = [1, 1]  # fact[n] = (n! mod p)
    factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
    inv = [0, 1]  # factinv 計算用
    
    for i in range(2, limitation + 1):
        fact.append((fact[-1] * i) % p)
        inv.append((-inv[p % i] * (p // i)) % p)
        factinv.append((factinv[-1] * inv[-1]) % p)
    
    def nHr(n,r,mod):
        # (n+r-1 C r)
        return nCr(n+r-1,r,mod)
    
    
    '''
    嘘つき大学を固まらせたほうがいい
    K人以上
    一旦N,Mで考える
    これだと、N-1 + M-1になる
    この組み合わせは、(N-1)! * M!
    
    ここから、Nを一人Mの中に入れると、N-2 + M-2になる。つまり、2減る
    そして、組み合わせは、(N-2)! * M! * m-1C1になる
    また、NとMは入れ替えてもよいから、大きいほうで考える
    
    あーーー
    横並びで挿入されるパターンもある
    これじゃあK個以上の判定はどうやってする
    
    i H M-i
    これは、嘘つきの集団にあらかじめ一つ配っておくから
    M+i-1-i C i-1
    '''
    
    N,M,K = map(int, input().split())
    
    ans = 0
    i = 1
    while i <= M:
        if N < i:
            continue
        if (N-i) + (M-i) < K:
            i += 1
            continue
        ans += nCr(N,i,mod1)%mod1*nCr(M+i-1-i,i-1,mod1)
        ans %= mod1
        i += 1
    
    print(ans*fact[N-1]%mod1*fact[M]%mod1)
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
if __name__ == '__main__':
    main()
0