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/1174
🧭 풀이 시간
30분
👀 체감 난이도
✏️ 문제 설명
음이 아닌 정수를 십진법으로 표기했을 때 왼쪽부터 자릿수가 감소할 때 (ex: 321, 540 등) 이 수를 감소하는 수라고 합니다.
N번째로 작은 줄어드는 수를 구하는 문제입니다.
🔍 풀이 방법
BFS를 이용해서 풀었습니다.
큐에 1~9를 넣으면서 만들 수 있는 모든 줄어드는 수를 구했습니다.
이 때 줄어드는 수 마다 count를 이용해서 갯수를 세고, N에 도착하면 그 수를 출력했습니다.
이 때 큐가 빌 때 까지 N에 다다르지 않으면 -1을 출력했습니다.
⏳ 회고
풀면서 이 방식이 맞나..? 생각 했었는데 0123456789 로 만들 수 있는 줄어드는 수의 갯수가 약 1000개로 많지 않아서 통했던 것 같습니다.