結果

問題 No.895 MESE
ユーザー MNGOFMNGOF
提出日時 2019-09-30 03:12:59
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,892 ms / 2,000 ms
コード長 1,277 bytes
コンパイル時間 97 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 34,560 KB
最終ジャッジ日時 2024-04-14 07:44:25
合計ジャッジ時間 31,460 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 277 ms
34,432 KB
testcase_01 AC 266 ms
34,432 KB
testcase_02 AC 267 ms
34,432 KB
testcase_03 AC 275 ms
34,432 KB
testcase_04 AC 273 ms
34,432 KB
testcase_05 AC 271 ms
34,432 KB
testcase_06 AC 266 ms
34,432 KB
testcase_07 AC 269 ms
34,432 KB
testcase_08 AC 274 ms
34,432 KB
testcase_09 AC 284 ms
34,432 KB
testcase_10 AC 284 ms
34,432 KB
testcase_11 AC 291 ms
34,432 KB
testcase_12 AC 279 ms
34,432 KB
testcase_13 AC 808 ms
34,432 KB
testcase_14 AC 1,654 ms
34,432 KB
testcase_15 AC 1,722 ms
34,432 KB
testcase_16 AC 1,143 ms
34,432 KB
testcase_17 AC 402 ms
34,432 KB
testcase_18 AC 1,881 ms
34,432 KB
testcase_19 AC 1,867 ms
34,560 KB
testcase_20 AC 1,884 ms
34,432 KB
testcase_21 AC 1,891 ms
34,432 KB
testcase_22 AC 1,873 ms
34,432 KB
testcase_23 AC 1,875 ms
34,560 KB
testcase_24 AC 1,875 ms
34,432 KB
testcase_25 AC 1,890 ms
34,432 KB
testcase_26 AC 1,877 ms
34,432 KB
testcase_27 AC 1,869 ms
34,432 KB
testcase_28 AC 1,892 ms
34,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 二分乗数法
def my_dif(a, b, m):
    # a-b
    tmp = a - b
    return tmp if tmp > 0 else tmp + m


def my_pow(a, n, m, r=1):
    # [a, n, m, r] = [底, 指数, 返値の最大値, 初項]
    a %= m
    if n % 2 == 1:
        r *= a
        r %= m
    if n <= 1:
        return r
    a *= a
    a %= m
    return my_pow(a, int(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]
tmp = 1
for i in range(2, 300000):
    tmp *= i
    tmp %= output_max
    my_fact.append(tmp)

# 2のべき乗のチートシート作成
my_2xp = [1]
tmp = 1
for i in range(1, 300000):
    tmp *= 2
    tmp %= output_max
    my_2xp.append(tmp)

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

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