File tree Expand file tree Collapse file tree 1 file changed +55
-0
lines changed
Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Original file line number Diff line number Diff line change 1+ ``` java
2+ import java.io.* ;
3+ import java.util.ArrayList ;
4+ import java.util.Collections ;
5+ import java.util.List ;
6+
7+ public class BJ_1038_ 감소하는_수 {
8+
9+ private static final BufferedReader br = new BufferedReader (new InputStreamReader (System . in));
10+ private static final BufferedWriter bw = new BufferedWriter (new OutputStreamWriter (System . out));
11+
12+ private static int N ;
13+ private static List<Long > nums;
14+
15+ public static void main (String [] args ) throws IOException {
16+ if (init()) {
17+ for (int i = 0 ; i <= 9 ; i++ ) {
18+ sol(i);
19+ }
20+ Collections . sort(nums);
21+ bw. write(nums. get(N ) + " " );
22+ }
23+ bw. flush();
24+ bw. close();
25+ br. close();
26+ }
27+
28+ private static boolean init () throws IOException {
29+ N = Integer . parseInt(br. readLine());
30+
31+ if (N <= 10 ) {
32+ bw. write(N + " " );
33+ return false ;
34+ } else if (N >= 1023 ) {
35+ bw. write(" -1" );
36+ return false ;
37+ }
38+ nums = new ArrayList<> ();
39+
40+ return true ;
41+ }
42+
43+ private static void sol (long num ) throws IOException {
44+ nums. add(num);
45+
46+ long mod = num % 10 ;
47+ if (mod == 0 ) return ;
48+
49+ for (int i = 0 ; i < mod; i++ ) {
50+ sol(num * 10 + i);
51+ }
52+ }
53+
54+ }
55+ ```
You can’t perform that action at this time.
0 commit comments