A - Ignatius and the Princess II
STL中的algorithm 的全排列应用
#include<stdio.h> #include<string.h> #include<algorithm> #define INF 0x3f3f3f3f #define ll long long #define N 100010 using namespace std; int a[N]; int main() { int n,m; while(scanf("%d%d",&n,&m)!=EOF) { for(int i=1;i<=n;i++) a[i]=i; int k=1; while(next_permutation(a+1,a+n+1))//全排列函数 { k++; if(k==m) break; } for(int i=1;i<n;i++) printf("%d ",a[i]); printf("%d\n",a[n]); } return 0; }
(这为博客找的解题代码)
原文地址:https://www.cnblogs.com/kangdong/p/8453620.html
时间: 2024-10-30 06:41:22