We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3e6c64c commit 68be926Copy full SHA for 68be926
200218/Solution_programmers_줄서는방법_육성현.java
@@ -0,0 +1,28 @@
1
+import java.util.ArrayList;
2
+import java.util.Arrays;
3
+import java.util.List;
4
+
5
+class Solution {
6
+ long f[] = new long[21];
7
+ public int[] solution(int n, long k) {
8
+ int[] answer = new int[n];
9
+ make_f();
10
+ List<Integer> list = new ArrayList<>();
11
+ for(int i=0;i<n;i++){
12
+ list.add(i+1);
13
+ }
14
+ int x = 0;
15
16
+ x = (int)((k-1)/f[n-1-i]);
17
+ answer[i] = list.remove(x);
18
+ k = k-(x*f[n-1-i]);
19
20
+ return answer;
21
22
+ public void make_f(){
23
+ f[0] = 1;
24
+ for(int i=1;i<=20;i++){
25
+ f[i] = f[i-1]*(long)i;
26
27
28
+}
0 commit comments