跳过导航链接
Home Page
Problems
Status
Contests
Ranklist
F.A.Qs

第m个排列
Time Limit:1000MS  Memory Limit:32768K

Description:

1—n的排列共有n!种,把这n!种排列按字典序顺序排列。比如n=3时,所有的排列是 123,132,213,231,312,321.现在告诉你n(n<10,n>=1)和m(m<=n!),你能不能求出1—n的所有排列按字典序排列后的第m个排列是多少?

Input:

每一行都有两个整数n和m(n>=1,n<10,m<=n!),代表一组输入数据,n==0,m==0表示输入结束。

Output:

对于每一组数据,输出1—n的排列中的第m个排列。

Sample Input:

1 1
2 2
3 2
4 5
8 123
0 0

Sample Output:

1
21
132
1423
12435768
Submit Your Solution


Zhe Jiang University Of Technology Online Programming Space Beta1.4
Designed & Developped By Jin Qiwei 
Copyright © 2006-2009, All rights reserved.
53:36