首页 > 其他 > 详细

ignitius and princess 2(全排列)

时间:2018-02-19 11:53:14      阅读:250      评论:0      收藏:0      [点我收藏+]

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;  
} 

(这为博客找的解题代码)

 

ignitius and princess 2(全排列)

原文:https://www.cnblogs.com/kangdong/p/8453620.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!