您的位置:首页 > 其它

hdu 1027 next_permutation()

2016-08-23 17:04 323 查看
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=1027

#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int m,n;
int a[10001];
while(cin>>n>>m)
{
int i;
for(i=1;i<=n;i++)
a[i]=i;
int j=0;
while(next_permutation(a+1,a+n+1))
{
j++;
if(j==m-1)
{
for(int k=1;k<n;k++)
cout<<a[k]<<" ";
cout<<a
<<endl;
break;
}

}
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: