Rank and unrank permutations with just one cycle
问题 I want to rank and unrank permutations with one cycle in lexicographical order with a given len. A permutation with one cycles is where you can visit in this cycle each element. p:= (2,3,1) is a permutation with one cycle. Has rank 1. p:= (3,1,2) has 1 cycle too, but rank 2, because the permutation is lexicographical greater the frist so it becomes a greater rank. p:= (1,2,3) is a permutation with 3 cycles. (1),(2),(3) How can I efficently rank (permutation with one cycle to rank) and unrank