We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 376fe03 + 4ef86e0 commit 6b70057Copy full SHA for 6b70057
suyeun84/202507/14 BOJ G5 감소하는 수.md
@@ -0,0 +1,31 @@
1
+ ```java
2
+import java.util.*;
3
+import java.io.*;
4
+
5
+public class boj1038 {
6
+ static List<Long> arr = new ArrayList<>();
7
8
+ public static void main(String[] args) throws Exception{
9
+ BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
10
+ int N = Integer.parseInt(br.readLine());
11
12
+ if(N <= 10) System.out.println(N);
13
+ else{
14
+ for(int i = 0; i < 10; i++) set(i, 1);
15
+ if(N >= arr.size()) System.out.println(-1);
16
17
+ Collections.sort(arr);
18
+ System.out.println(arr.get(N));
19
+ }
20
21
22
23
+ static void set(long num, int val){
24
+ if(val > 10) return;
25
+ arr.add(num);
26
+ for(int i = 0; i < num % 10; i++){
27
+ set((num * 10) + i, val + 1);
28
29
30
+}
31
+```
0 commit comments