結果

問題 No.1035 Color Box
ユーザー c-yanc-yan
提出日時 2020-04-25 05:44:18
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 486 bytes
コンパイル時間 238 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 14,720 KB
最終ジャッジ日時 2024-04-23 19:33:14
合計ジャッジ時間 9,520 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 26 ms
10,880 KB
testcase_17 AC 26 ms
10,752 KB
testcase_18 AC 27 ms
10,752 KB
testcase_19 WA -
testcase_20 AC 26 ms
10,880 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 26 ms
10,752 KB
testcase_26 WA -
testcase_27 AC 26 ms
10,752 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

fac = [0] * (N + 1)
fac[0] = 1
for i in range(N):
    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

result = pow(M, N, 1000000007)
for i in range(1, M):
    result -= pow(i, N, 1000000007) * mcomb(N, i)
    result %= 1000000007
print(result)
0