Skip to content

Commit 6b70057

Browse files
authored
Merge pull request #461 from AlgorithmWithGod/suyeun84
[20250714] BOJ / G5 / 감소하는 수 / 김수연
2 parents 376fe03 + 4ef86e0 commit 6b70057

File tree

1 file changed

+31
-0
lines changed

1 file changed

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

Comments
 (0)