We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 1c10f0d + 2c7de6a commit 552802cCopy full SHA for 552802c
1 file changed
LiiNi-coder/202510/05 BOJ 감소하는 수.md
@@ -0,0 +1,36 @@
1
+```java
2
+import java.io.*;
3
+import java.util.*;
4
+
5
+public class Main {
6
+ static List<Long> list = new ArrayList<>();
7
8
+ public static void main(String[] args) throws IOException {
9
+ BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
10
+ int n = Integer.parseInt(br.readLine());
11
12
+ for(int i = 0; i < 10; i++){
13
+ dfs(i, 1);
14
+ }
15
16
+ Collections.sort(list);
17
+ // for(long l: list){
18
+ // System.out.print(l + ", ");
19
+ // }
20
+ if(n >= list.size()){
21
+ System.out.println(-1);
22
+ }else{
23
+ System.out.println(list.get(n));
24
25
26
27
+ static void dfs(long num, int depth){
28
+ list.add(num);
29
+ long last = num % 10;
30
+ for(int next = 0; next < last; next++){
31
+ dfs(num * 10 + next, depth + 1);
32
33
34
+}
35
36
+```
0 commit comments