結果

問題 No.1035 Color Box
ユーザー c-yanc-yan
提出日時 2020-06-21 01:31:03
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 899 ms / 2,000 ms
コード長 538 bytes
コンパイル時間 150 ms
コンパイル使用メモリ 10,820 KB
実行使用メモリ 31,008 KB
最終ジャッジ日時 2023-09-16 17:58:00
合計ジャッジ時間 8,960 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 899 ms
31,008 KB
testcase_01 AC 18 ms
8,252 KB
testcase_02 AC 15 ms
7,788 KB
testcase_03 AC 83 ms
9,836 KB
testcase_04 AC 88 ms
10,072 KB
testcase_05 AC 41 ms
8,752 KB
testcase_06 AC 22 ms
8,400 KB
testcase_07 AC 25 ms
8,344 KB
testcase_08 AC 791 ms
28,032 KB
testcase_09 AC 328 ms
16,240 KB
testcase_10 AC 16 ms
7,840 KB
testcase_11 AC 15 ms
7,816 KB
testcase_12 AC 16 ms
7,956 KB
testcase_13 AC 628 ms
23,656 KB
testcase_14 AC 717 ms
25,632 KB
testcase_15 AC 899 ms
30,960 KB
testcase_16 AC 15 ms
7,812 KB
testcase_17 AC 15 ms
7,848 KB
testcase_18 AC 15 ms
7,844 KB
testcase_19 AC 894 ms
30,928 KB
testcase_20 AC 16 ms
7,764 KB
testcase_21 AC 16 ms
7,924 KB
testcase_22 AC 15 ms
7,884 KB
testcase_23 AC 15 ms
7,848 KB
testcase_24 AC 15 ms
7,856 KB
testcase_25 AC 15 ms
7,788 KB
testcase_26 AC 15 ms
7,880 KB
testcase_27 AC 15 ms
7,816 KB
testcase_28 AC 15 ms
7,812 KB
testcase_29 AC 15 ms
7,812 KB
testcase_30 AC 15 ms
7,884 KB
testcase_31 AC 16 ms
7,796 KB
testcase_32 AC 15 ms
7,812 KB
testcase_33 AC 16 ms
7,848 KB
testcase_34 AC 16 ms
7,844 KB
testcase_35 AC 15 ms
7,764 KB
testcase_36 AC 15 ms
7,788 KB
testcase_37 AC 16 ms
7,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import setrecursionlimit

setrecursionlimit(10 ** 6)

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