From 4ef86e0d0865c6da6889f402485fe7df64701753 Mon Sep 17 00:00:00 2001 From: suyeun84 <81475092+suyeun84@users.noreply.github.com> Date: Mon, 14 Jul 2025 16:32:31 +0900 Subject: [PATCH] =?UTF-8?q?[20250714]=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=EA=B9=80?= =?UTF-8?q?=EC=88=98=EC=97=B0?= 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" | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 "suyeun84/202507/14 BOJ G5 \352\260\220\354\206\214\355\225\230\353\212\224 \354\210\230.md" diff --git "a/suyeun84/202507/14 BOJ G5 \352\260\220\354\206\214\355\225\230\353\212\224 \354\210\230.md" "b/suyeun84/202507/14 BOJ G5 \352\260\220\354\206\214\355\225\230\353\212\224 \354\210\230.md" new file mode 100644 index 00000000..95d4c4c6 --- /dev/null +++ "b/suyeun84/202507/14 BOJ G5 \352\260\220\354\206\214\355\225\230\353\212\224 \354\210\230.md" @@ -0,0 +1,31 @@ + ```java +import java.util.*; +import java.io.*; + +public class boj1038 { + static List arr = new ArrayList<>(); + + public static void main(String[] args) throws Exception{ + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + int N = Integer.parseInt(br.readLine()); + + if(N <= 10) System.out.println(N); + else{ + for(int i = 0; i < 10; i++) set(i, 1); + if(N >= arr.size()) System.out.println(-1); + else{ + Collections.sort(arr); + System.out.println(arr.get(N)); + } + } + } + + static void set(long num, int val){ + if(val > 10) return; + arr.add(num); + for(int i = 0; i < num % 10; i++){ + set((num * 10) + i, val + 1); + } + } +} +```