File tree 4 files changed +58
-0
lines changed
4 files changed +58
-0
lines changed Original file line number Diff line number Diff line change 225
225
| 03 | | [ Baekjoon-10972 ๋ค์ ์์ด] ( ./src/Permutation/P10972 ) | |
226
226
| 04 | | [ Baekjoon-10973 ์ด์ ์์ด] ( ./src/Permutation/P10973 ) | |
227
227
| 05 | | [ Baekjoon-10974 ๋ชจ๋ ์์ด] ( ./src/Permutation/P10974 ) | |
228
+ | 06 | | [ Baekjoon-9742 ์์ด] ( ./src/Permutation/P9742 ) | |
228
229
229
230
### Probability
230
231
Original file line number Diff line number Diff line change
1
+ package Permutation .P9742 ;
2
+
3
+ import java .io .*;
4
+ import java .util .*;
5
+
6
+ public class Main {
7
+
8
+ static String line , s ;
9
+ static int pos ;
10
+ static int [] fact = new int [11 ];
11
+
12
+ public static void main (String [] args ) throws Exception {
13
+ System .setIn (new FileInputStream ("src/Permutation/P9742/input.txt" ));
14
+ BufferedReader br = new BufferedReader (new InputStreamReader (System .in ));
15
+ BufferedWriter bw = new BufferedWriter (new OutputStreamWriter (System .out ));
16
+
17
+ fact [1 ] = 1 ;
18
+ for (int i = 2 ; i <= 10 ; i ++) fact [i ] = fact [i -1 ] * i ;
19
+
20
+ StringBuilder sb = new StringBuilder ();
21
+ while ((line = br .readLine ()) != null ) {
22
+ StringTokenizer st = new StringTokenizer (line );
23
+ sb .append (line ).append (" = " );
24
+
25
+ s = st .nextToken ();
26
+ pos = Integer .parseInt (st .nextToken ());
27
+
28
+ if (pos > fact [s .length ()]) sb .append ("No permutation" ).append ("\n " );
29
+ else {
30
+ pos --;
31
+ StringBuffer buf = new StringBuffer (s );
32
+ for (int i = s .length ()-1 ; i > 0 ; i --) {
33
+ sb .append (buf .charAt (pos /fact [i ]));
34
+ buf .deleteCharAt (pos /fact [i ]);
35
+ pos %= fact [i ];
36
+ }
37
+ sb .append (buf .charAt (0 )).append ("\n " );
38
+ }
39
+ }
40
+
41
+ bw .write (sb .toString ());
42
+ bw .flush ();
43
+ bw .close ();
44
+ br .close ();
45
+ }
46
+ }
Original file line number Diff line number Diff line change
1
+ ## [ baekjoon-9742] ์์ด
2
+
3
+ ![ image] ( https://user-images.githubusercontent.com/22045163/106979827-73cb5380-67a2-11eb-94b7-549cafdb4865.png )
4
+ ![ image] ( https://user-images.githubusercontent.com/22045163/106979878-8ba2d780-67a2-11eb-8231-cb33dfa3a189.png )
5
+
6
+ ![ image] ( https://user-images.githubusercontent.com/22045163/106980001-c86ece80-67a2-11eb-8608-6a3654252a5a.png )
Original file line number Diff line number Diff line change
1
+ 235 4
2
+ bein 20
3
+ 123456 700
4
+ mnpqr 130
5
+ tuvwxyz 4000
You canโt perform that action at this time.
0 commit comments