From 7c0145208eff1284a6fbec95ec0b411a01bd93fc Mon Sep 17 00:00:00 2001 From: JHLEE325 <82587652+JHLEE325@users.noreply.github.com> Date: Sat, 31 Jan 2026 19:05:13 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[20260131]=20BOJ=20/=20G5=20/=20=EC=A4=84?= =?UTF-8?q?=EC=96=B4=EB=93=9C=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\353\223\234\353\212\224 \354\210\230.md" | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 "JHLEE325/202601/31 BOJ G5 \354\244\204\354\226\264\353\223\234\353\212\224 \354\210\230.md" diff --git "a/JHLEE325/202601/31 BOJ G5 \354\244\204\354\226\264\353\223\234\353\212\224 \354\210\230.md" "b/JHLEE325/202601/31 BOJ G5 \354\244\204\354\226\264\353\223\234\353\212\224 \354\210\230.md" new file mode 100644 index 00000000..3d8524f4 --- /dev/null +++ "b/JHLEE325/202601/31 BOJ G5 \354\244\204\354\226\264\353\223\234\353\212\224 \354\210\230.md" @@ -0,0 +1,36 @@ +```java +import java.util.*; +import java.io.*; + +public class Main { + + static int[] nums = {9, 8, 7, 6, 5, 4, 3, 2, 1, 0}; + static List list = new ArrayList<>(); + + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + int N = Integer.parseInt(br.readLine()); + + for (int i = 0; i <= 9; i++) { + dfs(i, i); + } + + Collections.sort(list); + + if (N > list.size()) { + System.out.println("-1"); + } else { + System.out.println(list.get(N - 1)); + } + } + + static void dfs(long num, int lastDigit) { + list.add(num); + + for (int i = 0; i < lastDigit; i++) { + dfs(num * 10 + i, i); + } + } + +} +``` From a918703f2a511a5c9dff21852489926335b474bd Mon Sep 17 00:00:00 2001 From: JHLEE325 <82587652+JHLEE325@users.noreply.github.com> Date: Sat, 31 Jan 2026 19:10:26 +0900 Subject: [PATCH 2/4] =?UTF-8?q?[20260131]=20BOJ=20/=20G5=20/=20=EC=A4=84?= =?UTF-8?q?=EC=96=B4=EB=93=9C=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\353\223\234\353\212\224 \354\210\230.md" | 46 +++++++++++-------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git "a/JHLEE325/202601/31 BOJ G5 \354\244\204\354\226\264\353\223\234\353\212\224 \354\210\230.md" "b/JHLEE325/202601/31 BOJ G5 \354\244\204\354\226\264\353\223\234\353\212\224 \354\210\230.md" index 3d8524f4..c87e1e7c 100644 --- "a/JHLEE325/202601/31 BOJ G5 \354\244\204\354\226\264\353\223\234\353\212\224 \354\210\230.md" +++ "b/JHLEE325/202601/31 BOJ G5 \354\244\204\354\226\264\353\223\234\353\212\224 \354\210\230.md" @@ -1,36 +1,44 @@ ```java -import java.util.*; import java.io.*; +import java.util.*; public class Main { - - static int[] nums = {9, 8, 7, 6, 5, 4, 3, 2, 1, 0}; - static List list = new ArrayList<>(); - public static void main(String[] args) throws Exception { 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, i); + if (N == 1) { + System.out.println(0); + return; } - Collections.sort(list); - - if (N > list.size()) { - System.out.println("-1"); - } else { - System.out.println(list.get(N - 1)); + Queue queue = new LinkedList<>(); + for (int i = 1; i <= 9; i++) { + queue.add((long) i); } - } - static void dfs(long num, int lastDigit) { - list.add(num); + int count = 1; + + while (!queue.isEmpty()) { + long current = queue.poll(); + count++; - for (int i = 0; i < lastDigit; i++) { - dfs(num * 10 + i, i); + if (count == N) { + System.out.println(current); + return; + } + + long lastDigit = current % 10; + + for (int i = 0; i < lastDigit; i++) { + long nextNum = (current * 10) + i; + queue.add(nextNum); + } } + + System.out.println("-1"); } - } ``` From acd4c6251bd2999f307dee2e2d2b4c1c567d8e99 Mon Sep 17 00:00:00 2001 From: JHLEE325 <82587652+JHLEE325@users.noreply.github.com> Date: Sat, 31 Jan 2026 19:13:01 +0900 Subject: [PATCH 3/4] =?UTF-8?q?Delete=20JHLEE325/202601/31=20BOJ=20G5=20?= =?UTF-8?q?=EC=A4=84=EC=96=B4=EB=93=9C=EB=8A=94=20=EC=88=98.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\353\223\234\353\212\224 \354\210\230.md" | 44 ------------------- 1 file changed, 44 deletions(-) delete mode 100644 "JHLEE325/202601/31 BOJ G5 \354\244\204\354\226\264\353\223\234\353\212\224 \354\210\230.md" diff --git "a/JHLEE325/202601/31 BOJ G5 \354\244\204\354\226\264\353\223\234\353\212\224 \354\210\230.md" "b/JHLEE325/202601/31 BOJ G5 \354\244\204\354\226\264\353\223\234\353\212\224 \354\210\230.md" deleted file mode 100644 index c87e1e7c..00000000 --- "a/JHLEE325/202601/31 BOJ G5 \354\244\204\354\226\264\353\223\234\353\212\224 \354\210\230.md" +++ /dev/null @@ -1,44 +0,0 @@ -```java -import java.io.*; -import java.util.*; - -public class Main { - public static void main(String[] args) throws Exception { - BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); - StringTokenizer st; - - int N = Integer.parseInt(br.readLine()); - - if (N == 1) { - System.out.println(0); - return; - } - - Queue queue = new LinkedList<>(); - for (int i = 1; i <= 9; i++) { - queue.add((long) i); - } - - int count = 1; - - while (!queue.isEmpty()) { - long current = queue.poll(); - count++; - - if (count == N) { - System.out.println(current); - return; - } - - long lastDigit = current % 10; - - for (int i = 0; i < lastDigit; i++) { - long nextNum = (current * 10) + i; - queue.add(nextNum); - } - } - - System.out.println("-1"); - } -} -``` From 83b9248cc339f526e04e1c91d0116d35ef9d8793 Mon Sep 17 00:00:00 2001 From: JHLEE325 <82587652+JHLEE325@users.noreply.github.com> Date: Sat, 31 Jan 2026 19:13:45 +0900 Subject: [PATCH 4/4] =?UTF-8?q?[20260131]=20BOJ=20/=20G5=20/=20=EC=A4=84?= =?UTF-8?q?=EC=96=B4=EB=93=9C=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 --- ...64\353\223\234\353\212\224\354\210\230.md" | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 "JHLEE325/202601/31 BOJ G5 \354\244\204\354\226\264\353\223\234\353\212\224\354\210\230.md" diff --git "a/JHLEE325/202601/31 BOJ G5 \354\244\204\354\226\264\353\223\234\353\212\224\354\210\230.md" "b/JHLEE325/202601/31 BOJ G5 \354\244\204\354\226\264\353\223\234\353\212\224\354\210\230.md" new file mode 100644 index 00000000..668b9fc9 --- /dev/null +++ "b/JHLEE325/202601/31 BOJ G5 \354\244\204\354\226\264\353\223\234\353\212\224\354\210\230.md" @@ -0,0 +1,44 @@ +```java +import java.io.*; +import java.util.*; + +public class Main { + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + StringTokenizer st; + + int N = Integer.parseInt(br.readLine()); + + if (N == 1) { + System.out.println(0); + return; + } + + Queue queue = new LinkedList<>(); + for (int i = 1; i <= 9; i++) { + queue.add((long) i); + } + + int count = 1; + + while (!queue.isEmpty()) { + long current = queue.poll(); + count++; + + if (count == N) { + System.out.println(current); + return; + } + + long lastDigit = current % 10; + + for (int i = 0; i < lastDigit; i++) { + long nextNum = (current * 10) + i; + queue.add(nextNum); + } + } + + System.out.println("-1"); + } +} +```