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); + } +} +```