[20260107] BOJ / G5 / 감소하는 수 / 이강현 #1776
Merged
+28
−0
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/1038
🧭 풀이 시간
40분
👀 체감 난이도
✏️ 문제 설명
음이아닌 정수를 앞자리부터 봤을때, 숫자가 감소하는 경우 감소하는 수라고 함.
N번째 감소하는 수를 구하자.
🔍 풀이 방법
비트마스킹
매 자릿수가 감소하려면 0~9까지의 숫자가 모두 사용되는 경우까지가 한계이므로
어떤 숫자를 사용할지 비트마스킹으로 표현함.
어떤 숫자를 사용할지가 선택되면 이후에는 내림차순 정렬을 한 것이 유일한 감소하는 수가 됨.
⏳ 회고
비트마스킹은 주어진 것 중에 어떤 것을 사용할지를 비트단위로 표현한 것이라는 생각을 문제 풀때 해보자.