Skip to content

Commit 552802c

Browse files
authored
Merge pull request #1050 from AlgorithmWithGod/LiiNi-coder
[20251005] BOJ / G5 / 감소하는 수 / 이인희
2 parents 1c10f0d + 2c7de6a commit 552802c

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)