Sample Input
6 4 //输出第4个全排列
11 8

Sample Output
1 2 3 5 6 4
1 2 3 4 5 6 7 9 8 11 10

 # include <cstdio>
# include <iostream>
# include <algorithm>
using namespace std ; int a[] ; int main ()
{
int n , m ;
while (scanf("%d %d" , &n , &m) != EOF)
{
int i ;
for (i = ; i <= n ;i++)
a[i] = i ;
int num = ;
while (num < m)
{
next_permutation(a+ , a++n) ;
num++ ;
}
for (i = ; i <= n- ;i++)
printf("%d " , a[i]) ;
printf("%d\n",a[n]) ;
}
}

hdu 1027 输出第m个全排列(next_permutation)的更多相关文章

  1. 关于全排列 next_permutation() 函数的用法

    这是一个c++函数,包含在头文件<algorithm>里面,下面是基本格式. 1 int a[]; 2 do{ 3 4 }while(next_permutation(a,a+n)); 下 ...

  2. HDU 6351.Beautiful Now-暴力、全排列、思维 (2018 Multi-University Training Contest 5 1002)

    2018 Multi-University Training Contest 5 6351.Beautiful Now 题意就是交换任意两个数字,问你交换k次之后的最小值和最大值. 官方题解: 哇塞, ...

  3. 全排列next_permutation()用法和构造函数赋值

    全排列next_permutation()用法 在头文件aglorithm里 就是1~n数组的现在的字典序到最大的字典序的依次增加.(最多可以是n!种情况) int a[n]; do{ }while( ...

  4. HDU 1027 Ignatius and the Princess II[DFS/全排列函数next_permutation]

    Ignatius and the Princess II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K ( ...

  5. HDU 1027 Ignatius and the Princess II(求第m个全排列)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1027 Ignatius and the Princess II Time Limit: 2000/10 ...

  6. (全排列)Ignatius and the Princess II -- HDU -- 1027

    链接: http://acm.hdu.edu.cn/showproblem.php?pid=1027 Ignatius and the Princess II Time Limit: 2000/100 ...

  7. HDU - 1027 Ignatius and the Princess II 全排列

    Ignatius and the Princess II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K ( ...

  8. hdu 1027 Ignatius and the Princess II(产生第m大的排列,next_permutation函数)

    题意:产生第m大的排列 思路:使用 next_permutation函数(头文件algorithm) #include<iostream> #include<stdio.h> ...

  9. HDU 1716:排列2(全排列)

    排列2 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submis ...

随机推荐

  1. Executor, ExecutorService 和 Executors 间的不同

    java.util.concurrent.Executor, java.util.concurrent.ExecutorService, java.util.concurrent. Executors ...

  2. Every-SG游戏

    参考自 石家庄二中 贾志豪 IOI2009国家集训队论文 <组合游戏略述—— 浅谈 SG 游戏的若干拓展及变形> 一.定义 游戏规则加上 对于还没有结束的所有单一游戏,游戏者必须对其进行决 ...

  3. C# Dictionary序列化/反序列化

    [Serializable] public class SerializableDictionary<TKey, TValue> : Dictionary<TKey, TValue& ...

  4. “微信小程序商城构建全栈应用”开发小记

    注意事项: 1.application\api\extra下的wx.php记得填写小程序的app_id.app_secret: 2.API测试小工具需要APPID:

  5. Spring源码学习资料

    未完待续.. github地址 https://github.com/spring-projects 学习地址 https://github.com/code4craft/tiny-spring 推荐 ...

  6. MRPT 安装使用

    1. 安装mrpt ( apt-get ) $ sudo apt-get install mrpt-apps libmrpt-dev 2. 下载mrpt-1.3 链接:https://github.c ...

  7. D3开发中的资料整理

    D3开发台阶比较高,需要对html,css,js非常熟练,还要对SVG非常熟悉,SVG不会就不要开发D3了,下面给大家推荐一本资料,为大家未来的开发提供便利. 这个框架产品不支持ie8,是这个产品的特 ...

  8. Python3 Win下安装 scipy

    没有利用Anaconda安装python库时可能遇到一些问题,例如直接 pip3 install scipy 可能报错,安装失败.原因是Scipy的安装需要依赖MKL库,官方的Numpy不包含MKL, ...

  9. L-BFGS算法(转载)

    转载链接:http://blog.csdn.net/itplus/article/details/21897715 前面的拟牛顿法.DFP.BFGS.L-BFGS算法简短总结一下就是: 牛顿法不仅使用 ...

  10. k64 datasheet学习笔记1---概述

    1.前言 k64 datasheet描述了Freescale MCU的特性.架构和编程模型,主要是面向使用MCU的系统架构和软件应用开发人员. 2.模块划分 datasheet主要按功能对模块进行划分 ...