結果

問題 No.895 MESE
ユーザー fuppy_kyoprofuppy_kyopro
提出日時 2019-09-10 01:44:41
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,477 ms / 2,000 ms
コード長 706 bytes
コンパイル時間 268 ms
コンパイル使用メモリ 10,876 KB
実行使用メモリ 31,952 KB
最終ジャッジ日時 2023-09-15 13:02:03
合計ジャッジ時間 22,148 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,960 KB
testcase_01 AC 16 ms
7,876 KB
testcase_02 AC 17 ms
7,828 KB
testcase_03 AC 16 ms
7,836 KB
testcase_04 AC 16 ms
8,020 KB
testcase_05 AC 16 ms
7,924 KB
testcase_06 AC 16 ms
7,924 KB
testcase_07 AC 16 ms
7,904 KB
testcase_08 AC 24 ms
8,236 KB
testcase_09 AC 23 ms
8,316 KB
testcase_10 AC 26 ms
8,496 KB
testcase_11 AC 26 ms
8,460 KB
testcase_12 AC 21 ms
8,304 KB
testcase_13 AC 770 ms
22,116 KB
testcase_14 AC 938 ms
21,860 KB
testcase_15 AC 1,032 ms
23,584 KB
testcase_16 AC 795 ms
21,016 KB
testcase_17 AC 661 ms
21,444 KB
testcase_18 AC 1,469 ms
31,784 KB
testcase_19 AC 1,471 ms
31,952 KB
testcase_20 AC 1,462 ms
31,792 KB
testcase_21 AC 1,460 ms
31,884 KB
testcase_22 AC 1,477 ms
31,808 KB
testcase_23 AC 1,472 ms
31,872 KB
testcase_24 AC 1,468 ms
31,952 KB
testcase_25 AC 1,474 ms
31,784 KB
testcase_26 AC 1,474 ms
31,884 KB
testcase_27 AC 1,468 ms
31,924 KB
testcase_28 AC 1,463 ms
31,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/Users/fushishita/.pyenv/shims/python

import sys

MOD = 1000000007
fact = [1]
rfact = [1]

def mod_inverse(x):
    return pow(x, MOD - 2, MOD)

def nCr(n, r):
    if r > n:
        return 0
    ret = fact[n]
    ret = ret * rfact[r] % MOD
    ret = ret * rfact[n - r] % MOD
    return ret

a, b, c = list(map(int, input().split()))
n = a + b + c

for i in range(1, n + 1):
    fact.append(fact[i - 1] * i % MOD)
    rfact.append(mod_inverse(fact[i]))

ans = 0
for i in range(1, a + 1):
    x = a + b + c - i - 1
    add = pow(2, x, MOD) - 1
    add = add * nCr(x - 1, c - 1) % MOD * nCr(x - 1 - (c - 1), b - 1) % MOD
    ans = (ans + add) % MOD
ans = (ans + MOD) % MOD
print('{}\n'.format(ans), end='')
0