#B3623. Arrange Students for a Photo
Arrange Students for a Photo
Arrange Students for a Photo
Given two integers n and k, where n represents the total number of students and k is the number of students to be selected for a photo, you are required to choose k distinct students out of n and arrange them in a line. Each arrangement should be printed in lexicographical order.
The total number of arrangements is given by the permutation formula:
\( P(n, k) = \frac{n!}{(n-k)!} \)
inputFormat
The input consists of two space-separated positive integers n and k on a single line.
outputFormat
Output all possible arrangements, each on a separate line. Every line should contain k space-separated integers, and the arrangements must be listed in lexicographical order.
sample
3 2
1 2
1 3
2 1
2 3
3 1
3 2
</p>