From c4fc8bd9eb0fd57d4e9573fbd2c64ff30ad515eb Mon Sep 17 00:00:00 2001 From: Jinyeong Seol Date: Thu, 6 Nov 2025 23:54:16 +0900 Subject: [PATCH] =?UTF-8?q?[20251106]=20BOJ=20/=20G5=20/=20=ED=95=98?= =?UTF-8?q?=EB=85=B8=EC=9D=B4=20=ED=83=91=20/=20=EC=84=A4=EC=A7=84?= =?UTF-8?q?=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0\354\235\264 \355\203\221.md\342\200\216" | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 "Seol-JY/202511/06 BOJ G5 \355\225\230\353\205\270\354\235\264 \355\203\221.md\342\200\216" diff --git "a/Seol-JY/202511/06 BOJ G5 \355\225\230\353\205\270\354\235\264 \355\203\221.md\342\200\216" "b/Seol-JY/202511/06 BOJ G5 \355\225\230\353\205\270\354\235\264 \355\203\221.md\342\200\216" new file mode 100644 index 00000000..280466dd --- /dev/null +++ "b/Seol-JY/202511/06 BOJ G5 \355\225\230\353\205\270\354\235\264 \355\203\221.md\342\200\216" @@ -0,0 +1,33 @@ +```java +import java.io.*; +import java.math.BigInteger; + +public class Main { + static StringBuilder sb = new StringBuilder(); + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + int n = Integer.parseInt(br.readLine()); + + BigInteger moveCount = BigInteger.TWO.pow(n).subtract(BigInteger.ONE); + sb.append(moveCount).append('\n'); + + if (n <= 20) { + hanoi(n, 1, 3, 2); + } + + System.out.print(sb); + } + + static void hanoi(int n, int from, int to, int aux) { + if (n == 1) { + sb.append(from).append(' ').append(to).append('\n'); + return; + } + + hanoi(n - 1, from, aux, to); + sb.append(from).append(' ').append(to).append('\n'); + hanoi(n - 1, aux, to, from); + } +} +```