Now our hero finds the door to the BEelzebub feng5166. He opens the door and finds feng5166 is about to kill our pretty Princess. But now the BEelzebub has to beat our hero first. feng5166 says, "I have three question for you, if you can work them out, I will release the Princess, or you will be my dinner, too." Ignatius says confidently, "OK, at last, I will save the Princess." 

"Now I will show you the first problem." feng5166 says, "Given a sequence of number 1 to N, we define that 1,2,3...N-1,N is the smallest sequence among all the sequence which can be composed with number 1 to N(each number can be and should be use only once in this problem). So it's easy to see the second smallest sequence is 1,2,3...N,N-1. Now I will give you two numbers, N and M. You should tell me the Mth smallest sequence which is composed with number 1 to N. It's easy, isn't is? Hahahahaha......" 

Can you help Ignatius to solve this problem?

Input

The input contains several test cases. Each test case consists of two numbers, N and M(1<=N<=1000, 1<=M<=10000). You may assume that there is always a sequence satisfied the BEelzebub's demand. The input is terminated by the end of file.

Output

For each test case, you only have to output the sequence satisfied the BEelzebub's demand. When output a sequence, you should print a space between two numbers, but do not output any spaces after the last number.

Sample Input

6 4
11 8

Sample Output

1 2 3 5 6 4
1 2 3 4 5 6 7 9 8 11 10
#include<bits/stdc++.h>
using namespace std; int main()
{
int n,m,a[1010];
while(scanf("%d%d",&n,&m)!=EOF)
{
m--;
for(int i=0;i<n;i++) a[i]=i+1;
while(m--)
{
next_permutation(a,a+n);
}
for(int i=0;i<n-1;i++) printf("%d ",a[i]);
printf("%d\n",a[n-1]);
} }

HDU-1027Ignatius and princess II的更多相关文章

  1. HDU——1027Ignatius and the Princess II(next_permutation函数)

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

  2. (全排列)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 ...

  3. 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 ...

  4. HDU 1027 Ignatius and the Princess II(康托逆展开)

    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 全排列

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

  6. hdu Ignatius and the Princess II

    Ignatius and the Princess II Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Ja ...

  7. 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 ( ...

  8. ACM-简单题之Ignatius and the Princess II——hdu1027

    转载请注明出处:http://blog.csdn.net/lttree Ignatius and the Princess II Time Limit: 2000/1000 MS (Java/Othe ...

  9. ACM-简单的主题Ignatius and the Princess II——hdu1027

    转载请注明出处:http://blog.csdn.net/lttree Ignatius and the Princess II Time Limit: 2000/1000 MS (Java/Othe ...

  10. hdu1027 Ignatius and the Princess II (全排列 &amp; STL中的神器)

    转载请注明出处:http://blog.csdn.net/u012860063 题目链接:http://acm.hdu.edu.cn/showproblem.php? pid=1027 Ignatiu ...

随机推荐

  1. 银联ISO8583报文解析过程

    主密钥: aabbccddeeff11223344556677889900 1.从签到报文中获取工作密钥,包括MACKEY明文,PINKEY明文 签到: 12-03-31 16:38:09----&g ...

  2. C#索引器与数组的区别

    1.索引器的索引值类型不限定为整数 2.索引器允许重载 3.索引器不是一个变量 4.索引器以函数签名方式this标识,而属性采用名称来标识,名称可以任意 5.索引器不能使用static来进行声明,属性 ...

  3. ThinkPHP6 核心分析:系统服务

    什么是系统服务?系统服务是对于程序要用到的类在使用前先进行类的标识的绑定,以便容器能够对其进行解析(通过服务类的 register 方法),还有就是初始化一些参数.注册路由等(不限于这些操作,主要是看 ...

  4. Zabbix-(六) JMX监控

    Zabbix-(六) JMX监控 一.前言 Zabbix提供了JMX监控,它通过JMX API获取JVM信息,从而提供监控数据.本文讲述使用JMX监控Tomcat的JVM信息. 准备 Zabbix S ...

  5. vim可视化模式

    进入:v 移动光标选中 c剪切.y复制(自动退出v模式,进入插入模式) p粘贴

  6. 新一代开源即时通讯应用源码定制 运营级IM聊天源码

    公司介绍:我们是专业的IM服务提供商!哇呼Chat是一款包含android客户端/ios客户端/pc客户端/WEB客户端的即时通讯系统.本系统完全自主研发,服务器端源码直接部署在客户主机.非任何第三方 ...

  7. 十、CSR8670的DFU功能[补充]

    前一篇转载的博文很清楚,全面的介绍了DFU功能的实现步骤.关于DFU功能,你还需要知道以下信息: 一.image.fs,firmware,loader,psr之间的关系 图1-1 image.fs示意 ...

  8. DNS简单配置

    ——主要执行的程序:/usr/sbin/named ——系统服务:named ——默认端口:53 ——运行时的虚拟根环境:/var/named/chroot ——主配置文件:/etc/named.co ...

  9. 达梦关键字(如:XML,EXCHANGE,DOMAIN,link等)配置忽略

    背景:在使用达梦数据库时,查询SQL中涉及XML,EXCHANGE,DOMAIN,link字段,在达梦中是关键字,SQL报关键词不能使用的错误. 解决办法: 配置达梦安装文件E:\MyJava\dmd ...

  10. 性能测试专题:Locust工具实战之“蝗虫”降世

    阅读全文需5分钟. 1. 前言 在上一篇文章中,我们已经为大家介绍了什么是Locust,具体可参照:性能专题:Locust工具实战之开篇哲学三问,简单来说,Locust 是基于 Python 语言下的 ...