Problem : 1027 ( Ignatius and the Princess II ) Judge Status : Accepted
RunId : 6278648 Language : C++ Author : ssun
Code Render Status : Rendered By HDOJ C++ Code Render Version 0.01 Beta
#include "iostream"
#include "algorithm"
using namespace std;
int main(){
int arr[1010];
int i,m,n;
while(cin>>n>>m){
for(i=1; i<=n; i++){
arr[i] = i;
}
i = 0;
do{
i++;
if(i==m){
for(int k=1; k<=n; k++){
cout<<arr[k];
if(k == n)
cout<<endl;
else
cout<<" ";
}
}
}while(next_permutation(arr+n-7,arr+n+1));//由于m小于10000,所以从后面第八位开始排列
}
return 0;
}
HDU 1027 ( Ignatius and the Princess II )
最新推荐文章于 2025-11-25 10:31:53 发布
本文展示了一段使用C++解决排列问题的代码,通过循环和next_permutation函数实现序列的全排列输出。
163

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



