From 0ae3937bbe3b5202457f937936bd78ccff5b9abd Mon Sep 17 00:00:00 2001 From: SSUM <116950962+ssum21@users.noreply.github.com> Date: Fri, 30 Jan 2026 21:36:11 +0900 Subject: [PATCH] =?UTF-8?q?[Gold=20V]=20Title:=20=EB=82=983=EA=B3=B12,=20T?= =?UTF-8?q?ime:=2060=20ms,=20Memory:=2034924=20KB=20-BaekjoonHub?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 백준/Gold/16936. 나3곱2/README.md | 37 +++++++++++++++++++++++++++++ 백준/Gold/16936. 나3곱2/나3곱2.py | 39 +++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 백준/Gold/16936. 나3곱2/README.md create mode 100644 백준/Gold/16936. 나3곱2/나3곱2.py diff --git a/백준/Gold/16936. 나3곱2/README.md b/백준/Gold/16936. 나3곱2/README.md new file mode 100644 index 0000000..04569bb --- /dev/null +++ b/백준/Gold/16936. 나3곱2/README.md @@ -0,0 +1,37 @@ +# [Gold V] 나3곱2 - 16936 + +[문제 링크](https://www.acmicpc.net/problem/16936) + +### 성능 요약 + +메모리: 34924 KB, 시간: 60 ms + +### 분류 + +수학, 정렬, 해 구성하기 + +### 제출 일자 + +2026년 1월 30일 21:35:50 + +### 문제 설명 + +
나3곱2 게임은 정수 하나를 이용한다. 가장 먼저, 정수 x로 시작하고, 연산을 N-1번 적용한다. 적용할 수 있는 연산은 두 가지 있고, 아래와 같다.
+ +나3곱2 게임을 진행하면서, 만든 수를 모두 기록하면 수열 A를 만들 수 있다. 예를 들어, x = 9, N = 6이고, 적용한 연산이 곱2, 곱2, 나3, 곱2, 나3인 경우에 A = [9, 18, 36, 12, 24, 8] 이다.
+ +수열 A의 순서를 섞은 수열 B가 주어졌을 때, 수열 A를 구해보자.
+ +### 입력 + +첫째 줄에 수열의 크기 N(2 ≤ N ≤ 100)이 주어진다. 둘째 줄에는 수열 B가 주어진다. B에 포함된 원소는 1018 보다 작거나 같은 자연수이다.
+ +### 출력 + +나3곱2 게임의 결과 수열 A를 출력한다. 항상 정답이 존재하는 경우에만 입력으로 주어지며, 가능한 정답이 여러가지인 경우에는 아무거나 출력한다.
+ diff --git a/백준/Gold/16936. 나3곱2/나3곱2.py b/백준/Gold/16936. 나3곱2/나3곱2.py new file mode 100644 index 0000000..840648b --- /dev/null +++ b/백준/Gold/16936. 나3곱2/나3곱2.py @@ -0,0 +1,39 @@ +import sys +from collections import deque + +input = sys.stdin.readline +N = int(input()) +orig = list(map(int, input().split())) + +for start in orig: + arr = deque(orig) + answer = deque() + + arr.remove(start) + cur = start + answer.append(cur) + + while arr: + # 1) /3 우선 + if cur % 3 == 0: + div_value = cur // 3 + if div_value in arr: + arr.remove(div_value) + cur = div_value + answer.append(cur) + continue + + # 2) *2 + mul_value = cur * 2 + if mul_value in arr: + arr.remove(mul_value) + cur = mul_value + answer.append(cur) + continue + + # 다음 값이 없으면 이 start는 실패 + break + + if len(answer) == N: + print(' '.join(map(str, answer))) + break