[20250206] BOJ / 골드2 / 집합의 개수 / 권혁준 #54
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/2092
🧭 풀이 시간
14분
👀 체감 난이도
✏️ 문제 설명
1부터 T까지의 범위에 있는 수들이 총 A개 있다. 이들 중 K개를 골라서 집합을 만들 때, 가능한 집합의 개수를 세려 한다.
단, K의 범위는 1 ≤ S ≤ K ≤ B ≤ A로 한다. 즉, 두 정수 S, B를 입력받아서 K = S일 경우, …, K = B일 경우의 집합의 개수를 모두 더하려고 한다.
이 문제에서는 집합에 같은 원소가 여러 번 들어가도 되지만, 원소의 순서는 고려하지 않는다. (원소의 구성은 같고 순서만 다른 경우는 하나로 가정함.)
🔍 풀이 방법
순서를 고려하지 않아서 작은 수부터 넣어주는 경우만 고려했다.
위 정의 대로면 자연스럽게$dp[n][k] = \sum \limits_{i=0}^{cnt[n]} {dp[n-1][k-i]}$ 라는 식을 도출할 수 있고, 이대로 3중 반복문을 구현해줬다.
⏳ 회고
변수 이름이 정신 나간 것 같다.