結果

問題 No.1035 Color Box
ユーザー c-yanc-yan
提出日時 2020-04-26 18:01:05
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 481 bytes
コンパイル時間 81 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 14,720 KB
最終ジャッジ日時 2024-11-17 15:36:32
合計ジャッジ時間 5,856 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 RE * 1
other AC * 6 RE * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

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

fac = [0] * (M + 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 = 0
for i in range(1, M + 1):
    result = mcomb(M, i) * pow(i, N, 1000000007) - result
    result %= 1000000007

print(result)
0