Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
1. Organize the list of N elements in ascending order;
2. We will generate recursively (this is for simplicity of explanation, after mastering the idea, you can get by with a cycle);
2.1. If M==0, then exit from the recursion;
2.2. The first placement element is the element in the Lth position in the list, where L=((N*m-1)\A(N,M))+1 (numbering from one for clarity only); A(N,M)= number of placements from N to M; remove the selected element from the list;
2.3. For the next recursion step, we take m=m-(L-1)*A(N,M)/N; N=N-1; M=M-1;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question