結果

問題 No.1035 Color Box
ユーザー rlangevinrlangevin
提出日時 2023-01-30 08:57:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 138 ms / 2,000 ms
コード長 542 bytes
コンパイル時間 328 ms
コンパイル使用メモリ 87,120 KB
実行使用メモリ 86,048 KB
最終ジャッジ日時 2023-09-12 12:07:37
合計ジャッジ時間 6,812 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
85,996 KB
testcase_01 AC 88 ms
84,012 KB
testcase_02 AC 91 ms
83,912 KB
testcase_03 AC 94 ms
84,484 KB
testcase_04 AC 96 ms
84,372 KB
testcase_05 AC 94 ms
84,364 KB
testcase_06 AC 90 ms
84,172 KB
testcase_07 AC 90 ms
83,912 KB
testcase_08 AC 132 ms
85,956 KB
testcase_09 AC 108 ms
84,972 KB
testcase_10 AC 87 ms
84,076 KB
testcase_11 AC 87 ms
84,168 KB
testcase_12 AC 88 ms
84,180 KB
testcase_13 AC 128 ms
85,720 KB
testcase_14 AC 135 ms
85,712 KB
testcase_15 AC 137 ms
86,048 KB
testcase_16 AC 88 ms
84,000 KB
testcase_17 AC 87 ms
84,116 KB
testcase_18 AC 89 ms
83,988 KB
testcase_19 AC 138 ms
85,976 KB
testcase_20 AC 90 ms
84,008 KB
testcase_21 AC 89 ms
83,908 KB
testcase_22 AC 90 ms
84,232 KB
testcase_23 AC 87 ms
84,300 KB
testcase_24 AC 90 ms
84,236 KB
testcase_25 AC 88 ms
84,020 KB
testcase_26 AC 89 ms
84,068 KB
testcase_27 AC 90 ms
84,016 KB
testcase_28 AC 88 ms
83,988 KB
testcase_29 AC 88 ms
83,904 KB
testcase_30 AC 93 ms
84,068 KB
testcase_31 AC 89 ms
84,180 KB
testcase_32 AC 88 ms
84,004 KB
testcase_33 AC 87 ms
84,012 KB
testcase_34 AC 89 ms
83,908 KB
testcase_35 AC 89 ms
84,064 KB
testcase_36 AC 88 ms
84,180 KB
testcase_37 AC 89 ms
84,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M = map(int, input().split())
mod = 10 ** 9 + 7

n = 505050

fact = [1] * (n + 1)
invfact = [1] * (n + 1)
for i in range(1, n):
    fact[i + 1] = ((i+1) * fact[i]) % mod
invfact[n] = pow(fact[n], mod - 2, mod)
for i in range(n - 1, -1, -1):
    invfact[i] = invfact[i + 1] * (i + 1) % mod

def comb(n, r):
    if n < 0 or r < 0 or n - r < 0:
        return 0
    return fact[n] * invfact[r] * invfact[n - r] % mod

pm = 1
ans = 0
for i in range(M + 1):
    ans += comb(M, i) * pow(M - i, N, mod) * pm
    ans %= mod
    pm *= -1
print(ans)
0