[20250211] BOJ / 플래3 / 도형 / 권혁준 #76
Merged
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/1121
🧭 풀이 시간
20분
👀 체감 난이도
✏️ 문제 설명
🔍 풀이 방법
둘레가$s$ 인 $k$ 각형의 가짓수를 $dp[s][k]$ 라고 정의하면, $O(500000 \times s \times k)$ 에 구할 수 있겠다 싶어서 이대로 구현했다.
길이$a$ 인 선분을 추가해서 둘레 $s$ 인 $k$ 각형을 만드는 것은, $s>2a$ 를 만족할 때, $k-1$ 개의 선분을 골라 길이 합이 $s-a$ 가 되는 가짓수를 더해주는 것과 동일하다. -> 배낭 문제로 생각할 수 있다.
위의 dp식 정의인$sum[s][k]$ 에 합의 가짓수를 따로 저장해주었다.
둘레가 $s$인 $k$각형의 가짓수와,$k$개의 합이 $s$가 되는 가짓수는 엄연히 다르기 때문에,⏳ 회고
배낭 문제를 연습하기에 좋은 문제같다.