File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 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+ ```
You can’t perform that action at this time.
0 commit comments