125602024-12-23 11:28:224rt3xp02015. októbercpp17Accepted 1ms500 KiB
#include<bits/stdc++.h>
using namespace std;

int main(){
  int n; long long k;
  cin >> n >> k; k--;
  vector<long long> fact(n,1); vector<int> v(n);
  for(int i=1;i<n;i++) fact[i]=fact[i-1]*i;
  for(int i=0;i<n;i++) v[i]=i+1;
  for(int i=n-1;i>0;i--){
    cout << v[k/fact[i]] << ' ';
    v.erase(v.begin()+k/fact[i]);
    k%=fact[i];
  }
  cout << v[0];
}
1 - Accepted
Memory: 320KiB
Time: 1ms

Program's output:
1 2 4 3
Expected output:
1 2 4 3 
Checker output:
ok 4 number(s): "1 2 4 3"

2 - Accepted
Memory: 320KiB
Time: 1ms

Program's output:
5 3 2 4 1
Expected output:
5 3 2 4 1 
Checker output:
ok 5 number(s): "5 3 2 4 1"

3 - Accepted
Memory: 320KiB
Time: 1ms

Program's output:
1
Expected output:
1 
Checker output:
ok 1 number(s): "1"

4 - Accepted
Memory: 320KiB
Time: 1ms

Program's output:
1 8 3 5 7 4 2 6 9
Expected output:
1 8 3 5 7 4 2 6 9 
Checker output:
ok 9 numbers

5 - Accepted
Memory: 320KiB
Time: 1ms

Program's output:
1 8 10 2 3 12 4 6 7 5 9 11
Expected output:
1 8 10 2 3 12 4 6 7 5 9 11 
Checker output:
ok 12 numbers

6 - Accepted
Memory: 320KiB
Time: 1ms

Program's output:
7 3 1 5 8 9 10 11 2 6 4
Expected output:
7 3 1 5 8 9 10 11 2 6 4 
Checker output:
ok 11 numbers

7 - Accepted
Memory: 320KiB
Time: 1ms

Program's output:
2 1
Expected output:
2 1 
Checker output:
ok 2 number(s): "2 1"

8 - Accepted
Memory: 320KiB
Time: 1ms

Program's output:
6 3 8 2 5 4 10 11 7 1 9
Expected output:
6 3 8 2 5 4 10 11 7 1 9 
Checker output:
ok 11 numbers

9 - Accepted
Memory: 320KiB
Time: 1ms

Program's output:
4 5 2 1 7 6 3
Expected output:
4 5 2 1 7 6 3 
Checker output:
ok 7 numbers

10 - Accepted
Memory: 320KiB
Time: 1ms

Program's output:
10 2 4 1 5 8 3 9 7 6
Expected output:
10 2 4 1 5 8 3 9 7 6 
Checker output:
ok 10 numbers

11 - Accepted
Memory: 320KiB
Time: 1ms

Program's output:
1
Expected output:
1 
Checker output:
ok 1 number(s): "1"

12 - Accepted
Memory: 320KiB
Time: 1ms

Program's output:
2 5 14 12 8 4 11 6 13 9 1 10 3 7
Expected output:
2 5 14 12 8 4 11 6 13 9 1 10 3 7 
Checker output:
ok 14 numbers

13 - Accepted
Memory: 500KiB
Time: 1ms

Program's output:
3 2 1
Expected output:
3 2 1 
Checker output:
ok 3 number(s): "3 2 1"

14 - Accepted
Memory: 320KiB
Time: 1ms

Program's output:
1 4 3 6 2 5
Expected output:
1 4 3 6 2 5 
Checker output:
ok 6 numbers

15 - Accepted
Memory: 320KiB
Time: 1ms

Program's output:
1
Expected output:
1 
Checker output:
ok 1 number(s): "1"

16 - Accepted
Memory: 320KiB
Time: 1ms

Program's output:
14 13 12 11 10 9 8 7 6 5 4 3 2 1
Expected output:
14 13 12 11 10 9 8 7 6 5 4 3 2 1 
Checker output:
ok 14 numbers

17 - Accepted
Memory: 320KiB
Time: 1ms

Program's output:
7 14 13 12 11 10 9 8 6 5 4 3 2 1
Expected output:
7 14 13 12 11 10 9 8 6 5 4 3 2 1 
Checker output:
ok 14 numbers