hdu 1027 输出第m个全排列(next_permutation)
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)的更多相关文章
- 关于全排列 next_permutation() 函数的用法
这是一个c++函数,包含在头文件<algorithm>里面,下面是基本格式. 1 int a[]; 2 do{ 3 4 }while(next_permutation(a,a+n)); 下 ...
- HDU 6351.Beautiful Now-暴力、全排列、思维 (2018 Multi-University Training Contest 5 1002)
2018 Multi-University Training Contest 5 6351.Beautiful Now 题意就是交换任意两个数字,问你交换k次之后的最小值和最大值. 官方题解: 哇塞, ...
- 全排列next_permutation()用法和构造函数赋值
全排列next_permutation()用法 在头文件aglorithm里 就是1~n数组的现在的字典序到最大的字典序的依次增加.(最多可以是n!种情况) int a[n]; do{ }while( ...
- 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 ( ...
- 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 ...
- (全排列)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 ...
- HDU - 1027 Ignatius and the Princess II 全排列
Ignatius and the Princess II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ( ...
- hdu 1027 Ignatius and the Princess II(产生第m大的排列,next_permutation函数)
题意:产生第m大的排列 思路:使用 next_permutation函数(头文件algorithm) #include<iostream> #include<stdio.h> ...
- HDU 1716:排列2(全排列)
排列2 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submis ...
随机推荐
- dubbo服务使用spring-data-mongodb进行时间查询的bug记录
一.项目情况:spring-boot+mongodb+dubbo. 二.问题:调用dubbo服务并使用spring-data-mongodb的gte,lte时间段比较查询, @Reference(re ...
- 运维数据库平台~inception测试脚本
一 简介:今天咱们来聊聊inception的测试脚本 二 范例: #!/usr/bin/python import MySQLdb sql='/*--user=;--password=;--host= ...
- CentOS7_JDK安装和环境变量配置
1.下载 curl -O http://download.Oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.tar.gz 2.改名 mv ...
- Jetson tk1 安装 usbtoserials 驱动(重新刷机)
一.tk1驱动包,文件系统和源码下载 截止2016年9月1号,tk1最版本为R21.5. (以下三个文件放在同一个文件夹下) 1.driver package(驱动包,相当于安装程序) https:/ ...
- ubuntu下安装搜狗输入法以及出现不能输入中文的解决办法
1. 官网下载安装包 http://pinyin.sogou.com/linux/?r=pinyin 下载你需要的版本,这里选择64位版. 2. 进入软件中心安装 3. 修改ibus为fcitx im ...
- ProcessHacker可编译版本
说明 做一个批量进程内搜索字符串的工具. 试了processhacker-2.39-src.zip. https://sourceforge.net/projects/processhacker/fi ...
- WCF错误远程服务器返回了意外响应: (413) Request Entity Too Large。解决方案
这个问题出现的原因是 调用wcf服务的时候传递的参数 长度太大 wcf数据传输采用的默认的大小是65535字节. ---------------------------------------- ...
- shell script中read的用法
1.read基本读取 #!/bin/bash #testing the read command echo -n "Enter you name:" #echo -n 让用户直接在 ...
- NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{HBmUtjMOQP2pgLFFwqa_Og}{172.16.0.163}{172.16.0.163:9300}] ]
1.找到elasticsearch的安装目录,在config目录找到elasticsearch.yml,查看cluster.name的赋值 2.在SpringBoot的yml文件中,不仅要配置clus ...
- Java快速学习笔记01
这一波快速学习主要是应付校招笔面试用,功利性质不可避免. 学习网址: http://www.runoob.com/java/java-tutorial.html 执行命令解析: 以上我们使用了两个命令 ...