[20250317] BOJ / G4 / 1과 5 / 권혁준 #254
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/33615
🧭 풀이 시간
25분
👀 체감 난이도
✏️ 문제 설명
1과 5만으로 이루어진 양의 정수 N에서, 원하는 위치의 숫자 하나를 제거할 수 있다.
N이 합성수가 될 수 있다면 몇 번째 숫자를 제거해야 하는지와, 얻어진 수의 약수를 아무거나 하나 출력해보자.
🔍 풀이 방법
[사용한 알고리즘]
N이 숫자 5로 끝난다면?
=> 무조건 5의 배수이다.
아니면...
N의 자릿수를 모두 더해보자.
자릿수 합이 3의 배수이면?
N도 3의 배수이다.
자릿수 합이 (3의 배수 + 1) 꼴이라면?
N에서 아무 1이나 하나 빼면 3의 배수가 된다.
자릿수 합이 (3의 배수 + 2) 꼴이라면..?
N에서 아무 5나 하나 빼면 3의 배수가 된다.
5가 없다면,,,,
자릿수 합이 짝수라면?
N은 11의 배수다.
자릿수 합이 홀수라면?
N에서 아무 1이나 하나 빼면 11의 배수가 된다.
...
⏳ 회고
이런 유형은 살면서 처음 본다 다시는 보고 싶지 않다