蓝桥杯-排列数
使用STL->next_permutation();
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
int main() {
int count = 0;
int n;
scanf("%d", &n);
string s1 = "0123456789";
do {
count++;
if (count == n) {
cout << s1 << endl;
}
}while(next_permutation(s1.begin(), s1.end()));
return 0;
}
速度慢了点 不过可以使用dfs来优化

本文介绍了一种使用STL next_permutation()函数解决蓝桥杯竞赛中排列数问题的方法。通过C++代码示例展示了如何生成指定位置的全排列序列。

701

被折叠的 条评论
为什么被折叠?



