-->
当前位置:首页 > 题库

PROGRAMMING:Full Permutation

Luz5年前 (2021-05-10)题库384
LC learned the complete permutation of numbers in class today, and LC thought that the complete permutation of numbers was very simple, but until LC's deskmate yooq asked him a question, which was described as follows: we know that the total permutation of n is n! For example, the total permutation of 2 has two sequences {1,2} and {2,1}. Now the problem you want to solve is the total permutation of n! What is the m-th sequence among the sequences( Note: the full permutation of n is n! Sequences are sorted from small to large in dictionary order)
###Input format:
In the first row, the number of sample groups t (t ≤ 1E5), and in the next row, each row has an integer n and m (1 < = n < = 20, 1 < = m < = n!)
###Output format:
Output t lines, each line output n full permutation of n! In the m-th sequence, there is a space between two adjacent numbers, and there must be no extra space at the end of the line.
###Input example:
Here is a set of inputs. For example:
```in
two
1 1
3 6
```
###Output example:
The corresponding output is given here. For example:
```out
one
3 2 1
```







answer:If there is no answer, please comment