'commit'
This commit is contained in:
36
TangDou/CSP-J/AcWingTraining/T5/420._1.cpp
Normal file
36
TangDou/CSP-J/AcWingTraining/T5/420._1.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
const int N = 10010;
|
||||
int n, m;
|
||||
int a[N];
|
||||
/*
|
||||
5
|
||||
3
|
||||
1 2 3 4 5
|
||||
|
||||
答案
|
||||
1 2 4 5 3
|
||||
|
||||
变化过程
|
||||
(1) 1 2 3 5 4
|
||||
(2) 1 2 4 3 5
|
||||
(3) 1 2 4 5 3
|
||||
*/
|
||||
int main() {
|
||||
cin >> n >> m;
|
||||
for (int i = 1; i <= n; i++) cin >> a[i];
|
||||
|
||||
while (m--) next_permutation(a + 1, a + 1 + n); // 输入数据保证这个结果不会超出火星人手指能表示的范围。
|
||||
|
||||
/*
|
||||
int a[4] = {1, 2, 3, 4};
|
||||
sort(a, a + 4);
|
||||
do {
|
||||
for (int i = 0; i < 4; i++) cout << a[i] << " ";
|
||||
cout << endl;
|
||||
} while (next_permutation(a, a + 4));
|
||||
*/
|
||||
|
||||
for (int i = 1; i <= n; i++) printf("%d ", a[i]);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user