[20251223] BOJ / G3 / 준오는 심술쟁이!! / 한종욱#1729
Merged
ShinHeeEul merged 1 commit intomainfrom Dec 23, 2025
Merged
Conversation
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.
🧷 문제 링크
https://www.acmicpc.net/problem/14437
🧭 풀이 시간
60분
👀 체감 난이도
✏️ 문제 설명
문제를 재해석하면, N개의 칸에 0~25까지의 수를 채워 넣을 때, 그 합이 s인 경우의 수는?
🔍 풀이 방법
dp[i][j]: i번째 칸까지의 합이 j인 경우의 수로 상태를 정의했다.
그렇게 해보면,
그런데 이렇게 문제를 풀면 3중 for문이 나와 시간초과가 발생한다.
두 점화식으로 미루어 보았을 때,
다음과 같은 누적합을 통해서 답을 구하면 된다.
⏳ 회고
MOD를 나눌 때, 위 식에선 음수가 될 수 도 있다. 따라서 MOD를 더한 다음 나머지를 구했는데, 이 식을 한꺼번에 계산하면 overflow가 발생할 수 있다. 이걸 몰라서 틀렸다. 더할 때, 한꺼번에 더하는 걸 습관화하지말고 자료형에 유의해서 계산하는 습관을 들이자.