結果

問題 No.895 MESE
ユーザー MNGOF
提出日時 2019-09-30 04:10:49
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 1,315 ms / 2,000 ms
コード長 934 bytes
コンパイル時間 221 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 34,560 KB
最終ジャッジ日時 2024-10-03 04:56:59
合計ジャッジ時間 23,368 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

def my_pow(a, n, m, r=1):
    if n % 2 == 1:
        r *= a
        r %= m
    if n <= 1:
        return r
    a *= a
    a %= m
    return my_pow(a, n // 2, m, r)


def my_mul(a, b, m):
    # a*b
    return ((a % m) * (b % m)) % m


def my_div(a, b, m):
    # a/b
    return my_mul(a, my_pow(b, m - 2, m), m)


output_max = 1000000000 + 7
s = input()
s = s.split()
inp = [int(tmp) for tmp in s]

a = inp[0]
b = inp[1]
c = inp[2]

my_fact = [-1, 1, 1]
tmp = 1
for i in range(2, 300000):
    tmp *= i
    tmp %= output_max
    my_fact.append(tmp)

my_2xp = [1]
tmp = 1
for i in range(1, 300000):
    tmp *= 2
    tmp %= output_max
    my_2xp.append(tmp)

res = 0
k = a + b + c - 1
for i in range(0, a):
    k -= 1
    tmp = my_2xp[k] - 1
    tmp = (tmp * my_fact[k]) % output_max
    res += my_div(tmp, my_fact[a - i], output_max)
    res %= output_max

res = my_div(res, (my_fact[b] * my_fact[c]) % output_max, output_max)
print(res)
0