結果

問題 No.1035 Color Box
ユーザー c-yanc-yan
提出日時 2020-06-21 07:51:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 902 ms / 2,000 ms
コード長 490 bytes
コンパイル時間 83 ms
コンパイル使用メモリ 10,896 KB
実行使用メモリ 31,024 KB
最終ジャッジ日時 2023-09-16 18:05:16
合計ジャッジ時間 8,071 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 902 ms
31,024 KB
testcase_01 AC 19 ms
8,080 KB
testcase_02 AC 16 ms
7,796 KB
testcase_03 AC 83 ms
9,980 KB
testcase_04 AC 88 ms
10,008 KB
testcase_05 AC 41 ms
8,792 KB
testcase_06 AC 22 ms
8,212 KB
testcase_07 AC 25 ms
8,268 KB
testcase_08 AC 783 ms
27,988 KB
testcase_09 AC 326 ms
16,124 KB
testcase_10 AC 15 ms
7,868 KB
testcase_11 AC 15 ms
7,764 KB
testcase_12 AC 15 ms
7,736 KB
testcase_13 AC 621 ms
23,540 KB
testcase_14 AC 714 ms
25,548 KB
testcase_15 AC 890 ms
30,900 KB
testcase_16 AC 15 ms
7,860 KB
testcase_17 AC 16 ms
7,920 KB
testcase_18 AC 15 ms
7,816 KB
testcase_19 AC 894 ms
30,936 KB
testcase_20 AC 16 ms
7,760 KB
testcase_21 AC 15 ms
7,812 KB
testcase_22 AC 15 ms
7,908 KB
testcase_23 AC 15 ms
7,868 KB
testcase_24 AC 15 ms
7,888 KB
testcase_25 AC 15 ms
7,800 KB
testcase_26 AC 15 ms
7,848 KB
testcase_27 AC 15 ms
7,800 KB
testcase_28 AC 15 ms
7,764 KB
testcase_29 AC 15 ms
7,756 KB
testcase_30 AC 15 ms
7,852 KB
testcase_31 AC 15 ms
7,912 KB
testcase_32 AC 15 ms
7,740 KB
testcase_33 AC 15 ms
7,804 KB
testcase_34 AC 15 ms
7,784 KB
testcase_35 AC 15 ms
7,764 KB
testcase_36 AC 15 ms
7,780 KB
testcase_37 AC 15 ms
7,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import setrecursionlimit

setrecursionlimit(10 ** 6)

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

m = 1000000007

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


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], m - 2, m) * pow(fac[k], m - 2, m) % m


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


print(f(M))
0