卷王 @ 2022-11-01 20:15:28
#include<bits/stdc++.h>
using namespace std;
int n, k;
int a[20];
int main()
{
cin >> n >> k;
for(int i = 1; i <= n; i++) a[i] = i;
do
{
for(int i = 1; i <= k; i++) cout << a[i] << " ";
cout << endl;
} while(next_permutation(a + 1, a + n + 1));
return 0;
}
WA on #2
by 卷王 @ 2022-11-01 20:17:17
https://www.luogu.com.cn/record/92483718
by wheneveright @ 2022-11-01 20:27:36
input :
4 2
然后你就寄了
by 卷王 @ 2022-11-01 20:29:33
@wheneveright addd
by 卷王 @ 2022-11-01 20:30:13
@wheneveright 我问的就是怎样能过这样的样例
by WhtshpBlkhse @ 2022-11-17 10:40:00
再加句reverse,就可以过了。
#include <stdio.h>
#include <algorithm>
using namespace std;
int q[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, c;
int main()
{
int n, i, k;
scanf("%d%d", &n, &k);
do{
printf("%d", q[0]);
for(i = 1; i < k; i++) printf(" %d", q[i]);
puts("");
reverse(q + k, q + n);
}while(next_permutation(q, q + n));
return 0;
}
我的AC代码 @holdyhao_Genius
by 流光萤影 @ 2023-07-18 15:24:10
@岚羊央 为什么加上reverse()就能过a?