이하는 예전에 적었던 글들로 리뉴얼이 필요하다
dp = [[0] * M for _ in range(N)]
for i in range(N):
for j in range(M):
dp[i][j] = some_func(dp[:i], dp[i][:j])
print(dp[N - 1][M - 1])
dp_cur = [0] * M
for _ in range(N):
dp_cur, dp_prev = [0] * M, dp_cur
for i in range(M):
for j in range(N):
val = update(val, func(dp_prev[j]))
dp_cur[i] = val
print(dp_cur[M - 1])
dp_cur = {0: 0}
for i in range(N):
dp_cur, dp_prev = dp_cur.copy(), dp_cur
for prev_i, prev_v in dp_prev.items():
cur_i, cur_v = func(prev_i, prev_v)
dp_cur[cur_i] = cur_v
print(dp_cur[M-1])
for i in range(n.bit_length() + 1):
for num in range(n + 1):
if num & (1 << i):
dp[num] += dp[num ^ (1 << i)]
[To be filled]