結果

問題 No.1035 Color Box
ユーザー c-yanc-yan
提出日時 2020-04-26 18:02:09
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,118 ms / 2,000 ms
コード長 538 bytes
コンパイル時間 157 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 33,536 KB
最終ジャッジ日時 2024-04-28 20:19:28
合計ジャッジ時間 10,077 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,116 ms
33,408 KB
testcase_01 AC 34 ms
10,624 KB
testcase_02 AC 31 ms
10,624 KB
testcase_03 AC 112 ms
12,416 KB
testcase_04 AC 120 ms
12,544 KB
testcase_05 AC 62 ms
11,264 KB
testcase_06 AC 38 ms
10,880 KB
testcase_07 AC 42 ms
10,752 KB
testcase_08 AC 985 ms
30,336 KB
testcase_09 AC 414 ms
18,688 KB
testcase_10 AC 30 ms
10,624 KB
testcase_11 AC 31 ms
10,624 KB
testcase_12 AC 31 ms
10,624 KB
testcase_13 AC 782 ms
25,856 KB
testcase_14 AC 891 ms
28,032 KB
testcase_15 AC 1,118 ms
33,280 KB
testcase_16 AC 30 ms
10,752 KB
testcase_17 AC 30 ms
10,752 KB
testcase_18 AC 31 ms
10,752 KB
testcase_19 AC 1,118 ms
33,536 KB
testcase_20 AC 30 ms
10,624 KB
testcase_21 AC 30 ms
10,752 KB
testcase_22 AC 31 ms
10,624 KB
testcase_23 AC 30 ms
10,624 KB
testcase_24 AC 31 ms
10,624 KB
testcase_25 AC 31 ms
10,624 KB
testcase_26 AC 30 ms
10,624 KB
testcase_27 AC 30 ms
10,752 KB
testcase_28 AC 31 ms
10,624 KB
testcase_29 AC 30 ms
10,624 KB
testcase_30 AC 31 ms
10,880 KB
testcase_31 AC 30 ms
10,624 KB
testcase_32 AC 30 ms
10,624 KB
testcase_33 AC 31 ms
10,624 KB
testcase_34 AC 31 ms
10,752 KB
testcase_35 AC 30 ms
10,624 KB
testcase_36 AC 31 ms
10,624 KB
testcase_37 AC 31 ms
10,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import setrecursionlimit

setrecursionlimit(1000000)

N, M = map(int, input().split())

fac = [0] * (M + 1)
fac[0] = 1
for i in range(M):
    fac[i + 1] = fac[i] * (i + 1) % 1000000007


def mcomb(n, k):
    if n == 0 and k == 0:
        return 1
    if n < k or k < 0:
        return 0
    return fac[n] * pow(fac[n - k], 1000000005, 1000000007) * pow(fac[k], 1000000005, 1000000007) % 1000000007


def f(i):
    if i == 0:
        return 0
    return (mcomb(M, i) * pow(i, N, 1000000007) - f(i - 1)) % 1000000007


print(f(M))
0