File tree Expand file tree Collapse file tree 1 file changed +52
-0
lines changed
Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Original file line number Diff line number Diff line change 1+ ``` java
2+ import java.io.BufferedReader ;
3+ import java.io.IOException ;
4+ import java.io.InputStreamReader ;
5+ import java.util.* ;
6+
7+
8+ public class Main {
9+
10+ static int target,idx;
11+ static long [] decreasingNum;
12+
13+
14+ public static void main (String [] args ) throws IOException {
15+ init();
16+ process();
17+ print();
18+ }
19+
20+ private static void init () throws IOException {
21+ BufferedReader br = new BufferedReader (new InputStreamReader (System . in));
22+ target = Integer . parseInt(br. readLine());
23+ decreasingNum = new long [1000001 ];
24+ Arrays . fill(decreasingNum, - 1 );
25+ idx = 0 ;
26+ }
27+
28+ private static void process () throws IOException {
29+ for (int i = 1 ; i <= 10 ; i++ ){
30+ findNum(i- 1 ,0 ,10 );
31+ }
32+
33+ }
34+
35+ private static void findNum (int curPos , long curNum ,int limit ) {
36+ if (curPos == - 1 ){
37+ decreasingNum[idx++ ] = curNum;
38+ }
39+
40+ for (int i = 0 ; i < limit; i++ ){
41+ long tempNum = (long ) (curNum + Math . pow(10 ,curPos) * i);
42+ findNum(curPos- 1 ,tempNum,i);
43+
44+ }
45+ }
46+
47+
48+ private static void print () {
49+ System . out. println(decreasingNum[target]);
50+ }
51+ }
52+ ```
You can’t perform that action at this time.
0 commit comments