Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3441 Accepted Submission(s): 1740
Problem Description
Consider the aggregate An= { 1, 2, …, n }. For example, A1={1}, A3={1,2,3}. A subset sequence is defined as a array of a non-empty subset. Sort all the subset sequece of An in lexicography order. Your task is to find the m-th one.
Input
The input contains several test cases. Each test case consists of two numbers n and m ( 0< n<= 20, 0< m<= the total number of the subset sequence of An ).
Output
For each test case, you should output the m-th subset sequence of An in one line.
Sample Input
1 1
2 1
2 2
2 3
2 4
3 10
Sample Output
1
1 2
2
2 3 1
題意:給出n和m,然後有很多個集合{1,2,,,,n}的非空子集,按照一定方式排列,例如n==3時,
1 2
1 2 3
1 3
1 3 2
2 1
2 1 3
2 3
2 3 1
3
3 1
3 1 2
3 2
3 2 1
然後輸出第m個序列。
結題思路,仔細觀察可以看出,1、2、3開頭的集合個數是一樣多的,是以那m/(每組個數)可以得出第一個數字,然後依次類推即可