[20250622] BOJ / G2 / 칵테일 / 권혁준 #380
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/1033
🧭 풀이 시간
90분
👀 체감 난이도
✏️ 문제 설명
칵테일을 만드는 데 필요한 N개의 재료들의 비율이 트리 형태로 주어진다.
각 재료의 양이 정수이면서 최소가 되도록 하는 양을 구해보자.
🔍 풀이 방법
[사용한 알고리즘]
DFS로 일단 내 자식들과 나의 비율부터 맞춘 다음, 자식들을 차례로 갱신해준다.
갱신이 끝나면 다시 나를 루트로 갖는 서브트리의 최대공약수를 구해서 모두 나눠준다.
⏳ 회고
이거 너무 헷갈리고 개어려웠는데 왜 골드인지 진짜 모르겠다