Merged
Conversation
Mingguriguri
approved these changes
Apr 14, 2025
Collaborator
Mingguriguri
left a comment
There was a problem hiding this comment.
DP 문제가 난이도가 높으면 점화식부터 막히더라구요... 계단수는 아예 접근조차 못했던 것 같네요ㅠㅠ
겨우 겨우 이해했는데 다른 비트마스킹 문제를 더 풀어봐야 할 것 같아요..
그래도 1주 간 고생 많으셨습니다!
Comment on lines
+16
to
+20
Collaborator
There was a problem hiding this comment.
이 부분이 제 코드랑 다른 부분인 것 같네요!! else 부분 없이 조건을 이렇게 둬도 된다는 점을 배워갑니다!
# n: N번째 수
for n in range(2, N+1):
# last_digit: 마지막 자리 숫자
for last_digit in range(10):
# 0~9까지 모든 수를 방문해야 한다는 조건이 있으므로 방문여부를 비트마스킹을 통해 저장
for mask in range(1024):
if last_digit == 0:
dp[n][last_digit][mask | (1 << last_digit)] += dp[n - 1][last_digit + 1][mask]
elif last_digit == 9:
dp[n][last_digit][mask | (1 << last_digit)] += dp[n - 1][last_digit - 1][mask]
else:
dp[n][last_digit][mask | (1 << last_digit)] += (
dp[n - 1][last_digit - 1][mask] + dp[n - 1][last_digit + 1][mask]
)
dp[n][last_digit][mask | (1 << last_digit)] %= MOD
🔥2025-04 챌린지 진행 상황👉 그래프
👉 DP
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🌱WIL
🚀주간 목표 문제 수: 3개
백준 #10844. 쉬운 계단 수: DP / 실버1
정리한 링크: (바로가기)
🚩제출한 코드
💡TIL
백준 #1780. 종이의 개수: 재귀 / 실버2
정리한 링크: (바로가기)
🚩제출한 코드
💡TIL
print('\n'.join(str(v) for v in answer.values())): 딕셔너리의 값들을 개행 문자로 연결해서 출력하는 코드for k in sorted(answer.keys()): print(answer[k])백준 #1562. 계단수: DP / 골드1
정리한 링크: (바로가기)
🚩제출한 코드
💡TIL