From 801df8c130ba9a93d25605b70729a537b6d3e502 Mon Sep 17 00:00:00 2001 From: JHLEE325 <82587652+JHLEE325@users.noreply.github.com> Date: Fri, 10 Oct 2025 07:54:00 +0900 Subject: [PATCH] =?UTF-8?q?[20251010]=20BOJ=20/=20G5=20/=20=EA=B0=90?= =?UTF-8?q?=EC=86=8C=ED=95=98=EB=8A=94=20=EC=88=98=20/=20=EC=9D=B4?= =?UTF-8?q?=EC=A4=80=ED=9D=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\355\225\230\353\212\224 \354\210\230.md" | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 "JHLEE325/202510/10 BOJ G5 \352\260\220\354\206\214\355\225\230\353\212\224 \354\210\230.md" diff --git "a/JHLEE325/202510/10 BOJ G5 \352\260\220\354\206\214\355\225\230\353\212\224 \354\210\230.md" "b/JHLEE325/202510/10 BOJ G5 \352\260\220\354\206\214\355\225\230\353\212\224 \354\210\230.md" new file mode 100644 index 00000000..6c4a8c9c --- /dev/null +++ "b/JHLEE325/202510/10 BOJ G5 \352\260\220\354\206\214\355\225\230\353\212\224 \354\210\230.md" @@ -0,0 +1,39 @@ +```java +import java.io.*; +import java.util.*; + +public class Main { + + static ArrayList list = new ArrayList<>(); + + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + + int n = Integer.parseInt(br.readLine()); + + for (int i = 0; i <= 9; i++) { + dfs(i, 1); + } + + Collections.sort(list); + + if (n >= list.size()) { + System.out.println(-1); + } else { + System.out.println(list.get(n)); + } + } + + static void dfs(long num, int depth) { + list.add(num); + + long lastDigit = num % 10; + if (lastDigit == 0) return; + + for (int next = 0; next < lastDigit; next++) { + dfs(num * 10 + next, depth + 1); + } + } +} +```