[20251126] BOJ / P4 / 공약수 (More Huge) / 권혁준 #1517
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/27521
🧭 풀이 시간
60분
👀 체감 난이도
✏️ 문제 설명
쿼리 Q개를 처리해보자.
🔍 풀이 방법
두 정수 a, b에 대해, 서로소인 두 정수 p, q가 존재해 a = pG, b = qG, L = pqG를 만족함.
a+b를 최소화하는 것이 목표.
tie breaker는 p < q로 잡으면 unique가 보장될 듯?
p, q가 서로소려면, L/G의 소인수분해 결과에서 같은 소인수를 p,q가 나눠가지면 안 됨.
즉, 소인수분해 결과에서 나온 소인수 개수를 X라고 하면, O(2^X) 가능.
그리고 X <= 15임...
소인수 목록을 반 가르고 mitm 하면 O((X/2) * 2^(X/2))에 가능.
⏳ 회고
ez