[20251225] BOJ / D5 / Divine Divisor / 권혁준 #1739
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/8187
🧭 풀이 시간
90분
👀 체감 난이도
✏️ 문제 설명
정수 A의 어떤 약수 d에 대한 중복도 k는 다음과 같이 정의한다.
N개의 수가 주어지고, 정수 A를 이 N개 수의 곱으로 가정한다.
A의 약수 d의 중복도가 k이고, A의 약수 중 중복도가 k보다 큰 수가 없다면 d를 신성한 약수로 정의한다.
A의 신성한 약수의 중복도와, 신성한 약수의 개수를 구해보자.
🔍 풀이 방법
A를 소인수분해하여 모든 소인수를 뽑아낸다.
신성한 약수의 중복도는 곧 A의 소인수 중 가장 큰 중복도와 동일하다.
가장 큰 중복도를 k라고 하고 중복도가 k인 서로 다른 소인수의 개수를 c라고 하면, c개 소인수들 중에서 아무거나 뽑아서 각각 k번씩 곱하여 만든 모든 수가 신성한 약수가 된다.
-> 2^c - 1개.
⏳ 회고
저 신성한 약수의 개수가 엄청 커질 수 있어서 C++에서는 큰 수 연산을 딱히 지원하지 않아서 틀림.
Java로 다시 짰는데 메모리 초과가 남.
결국 파이썬으로 고쳐서 풀었다