結果

問題 No.2396 等差二項展開
ユーザー ecotteaecottea
提出日時 2023-02-25 02:08:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,348 ms / 6,000 ms
コード長 493 bytes
コンパイル時間 368 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 79,616 KB
最終ジャッジ日時 2024-04-16 04:37:21
合計ジャッジ時間 11,908 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
52,096 KB
testcase_01 AC 44 ms
52,352 KB
testcase_02 AC 42 ms
51,712 KB
testcase_03 AC 43 ms
52,096 KB
testcase_04 AC 42 ms
51,584 KB
testcase_05 AC 43 ms
51,968 KB
testcase_06 AC 43 ms
51,584 KB
testcase_07 AC 43 ms
51,840 KB
testcase_08 AC 43 ms
51,968 KB
testcase_09 AC 42 ms
51,712 KB
testcase_10 AC 43 ms
51,840 KB
testcase_11 AC 43 ms
51,712 KB
testcase_12 AC 43 ms
51,840 KB
testcase_13 AC 52 ms
59,520 KB
testcase_14 AC 52 ms
59,776 KB
testcase_15 AC 60 ms
61,824 KB
testcase_16 AC 254 ms
75,904 KB
testcase_17 AC 878 ms
78,464 KB
testcase_18 AC 1,348 ms
79,616 KB
testcase_19 AC 744 ms
76,416 KB
testcase_20 AC 45 ms
52,608 KB
testcase_21 AC 43 ms
52,224 KB
testcase_22 AC 43 ms
51,840 KB
testcase_23 AC 733 ms
77,824 KB
testcase_24 AC 556 ms
76,544 KB
testcase_25 AC 1,285 ms
78,464 KB
testcase_26 AC 629 ms
76,544 KB
testcase_27 AC 553 ms
76,672 KB
testcase_28 AC 1,244 ms
79,104 KB
testcase_29 AC 555 ms
76,672 KB
testcase_30 AC 811 ms
77,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m, l, k, MOD = map(int, input().split())

if l == 1:
   print(pow(m + 1, n, MOD))
   exit()

def mul(f, g):
    h = [0] * (2 * l)
    for i in range(l):
        for j in range(l):
            h[i + j] += f[i] * g[j]
            h[i + j] %= MOD
    
    for i in range(l):
        h[i] += h[i + l] * m
        h[i] %= MOD
    
    return h

f = [0] * l
f[0] = 1

p = [0] * l
p[0] = 1
p[1] = 1

while n > 0:
    if n % 2 == 1:
        f = mul(f, p)
    p = mul(p, p)
    n //= 2

print(f[k])
0