結果
問題 | No.2396 等差二項展開 |
ユーザー |
![]() |
提出日時 | 2023-07-28 23:06:06 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,104 ms / 6,000 ms |
コード長 | 856 bytes |
コンパイル時間 | 293 ms |
コンパイル使用メモリ | 81,908 KB |
実行使用メモリ | 76,324 KB |
最終ジャッジ日時 | 2024-10-06 21:03:50 |
合計ジャッジ時間 | 11,754 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 31 |
ソースコード
N, M, L, K, B = map(int, input().split())if L == 1:print(pow(1 + M, N, B))exit()now = [0] * Lnow[0] = now[1] = 1lst = []while N != 1:if N % 2 == 0:lst.append(1)N //= 2else:lst.append(0)N -= 1lst.reverse()for flag in lst:if flag:nex = [0] * (2 * L)for i in range(L):for j in range(L):nex[i + j] += now[i] * now[j]nex[i + j] %= Bfor i in range(L, 2 * L):nex[i - L] += nex[i] * Mnex[i - L - 1] %= Belse:nex = [0] * (L + 1)for i in range(L):nex[i] += now[i]nex[i + 1] += now[i]nex[i] %= Bnex[i + 1] %= Bnex[0] += nex[L] * Mnex[0] %= Bnow = nex[:L]print(now[K])