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. Java Calendar使用总结

    JavaCalendar 类时间操作,这也许是创建和管理日历最简单的一个方案,示范代码很简单. 演示了获取时间,日期时间的累加和累减,以及比较. 原文地址:blog.csdn.NET/joyous/a ...

  2. 一个简单的"RPC框架"代码分析

    0,服务接口定义---Echo.java /* * 定义了服务器提供的服务类型 */ public interface Echo { public String echo(String string) ...

  3. 在ASP.Net环境中,当用户点击报表中的超链接时如何调用Java Script方法?

    问题描述:在ASP.Net环境中,当用户点击报表中的超链接时如何调用Java Script方法? 问题解答: 你可以在TextObject.Hyperlink对象中编写js代码(javascript: ...

  4. Redis(二)冰叔带你了解Redis-哨兵模式和高可用集群解析

    前言    Redis 的 主从复制 模式下,一旦 主节点 由于故障不能提供服务,需要手动将 从节点 晋升为 主节点,同时还要通知 客户端 更新 主节点地址,这种故障处理方式从一定程度上是无法接受的. ...

  5. VMware workstation 网络选择 NAT模式 访问外网

    多年不用本地做测试  尽然被 nat 模式給卡着了  :动手的还是所以要记录一下: 1.根据自己需求创建 虚拟机 之后: 配置[网络适配器] -- 选择 nat 模式 ( 选择网卡 )   虚拟机   ...

  6. 近几年杭电OJ大型比赛题目合集【更新到2017年11月初】

    2017年: 区域赛网络赛   6194~6205    6206~6216 区域赛网络赛   6217~6229 2016年: 区域赛网络赛  5868~5877    5878~5891    5 ...

  7. HKE和他的小朋友(矩乘快速幂)

    题面: 题目背景: HKE带着\(n\)个小朋友做游戏 题目描述: 现在有n个座位编号为\(1\)至\(n\),这些小朋友也编号\(1\)至\(n\).一开始所有小朋友都坐在相应的座位上.HKE的游戏 ...

  8. JavaScript学习 - 基础(八) - DOM 节点 添加/删除/修改/属性值操作

    html代码: <!--添加/删除/修改 --> <div id="a1"> <button id="a2" onclick=&q ...

  9. Debian ifconfig 命令找不到

    如何配置让 Debian 非特权用户也可以使用 ifconfig . ifconfig 在 /sbin 目录下,新建一个用户时, Debian 默认从 /etc/skel/ 复制配置文件, /sbin ...

  10. 如何用ModelsimSE仿真IP核-以PLL为例

    我们之前介绍了如何使用Modelsim SE进行仿真和利用do文件的仿真方法,但是其中待仿真的模块是我们自己编写的Verilog模块,但是在实际工作中,我们的设计中会经常用到FPGA厂商给我们提供的现 ...