Skip to content

Commit 1a4be71

Browse files
authored
[20260107] BOJ / G5 / 감소하는 수 / 이강현
1 parent be7dd58 commit 1a4be71

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
```java
2+
3+
import java.util.*;
4+
import java.io.*;
5+
6+
public class Main {
7+
public static void main(String[] args) throws Exception {
8+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
9+
int N = Integer.parseInt(br.readLine());
10+
11+
List<Long> list = new ArrayList<>();
12+
13+
for (int i = 1; i < 1024; i++) {
14+
long num = 0;
15+
for (int j = 9; j >= 0; j--) {
16+
if ((i & (1 << j)) != 0) {
17+
num = num * 10 + j;
18+
}
19+
}
20+
list.add(num);
21+
}
22+
23+
Collections.sort(list);
24+
25+
System.out.println(N >= list.size() ? -1 : list.get(N));
26+
}
27+
}
28+
```

0 commit comments

Comments
 (0)