← RoseCode

ROSECODE 482

Period of permutation

liuguangxi · Math ·

Let i1,i2,i3,,in be a permutation of the set {1,2,3,...,n} where n is a positive integer. A permutation can also be viewed as a function f. We denote this permutation by the 2-by-n array f=(12ni1i2in) It maps number 1 to i1, number 2 to i2 and so on. When this function operates on a permutation of set 1,2,3,...,n, that is x1,x2,x3,,xn, a new permutation y1,y2,y3,,yn can be obtained. Here y1=f(x1),y2=f(x2),,yn=f(xn).

For example, when n=4 and there is a permutation 2,4,1,3. We make this permutation operate on a permutation 1,2,3,4 continuously, and it will be 1,2,3,42,4,1,34,3,2,13,1,4,21,2,3,4 Obviously after 4 operations the result permutation returns to the initial one.

Let F(l,p) be the number of permutations of the set {1,2,3,...,l} which makes the permutation 1,2,3,,l returns to itself after p operations. For instance, F(4,3)=9, as there are 9 permutations meet the condition: (1,2,3,4), (1,3,4,2), (1,4,2,3), (2,3,1,4), (2,4,3,1), (3,1,2,4), (3,2,4,1), (4,1,3,2), (4,2,1,3). You are also given F(5,5)=25, F(10,6)=625176, F(20,11)=609493248001.

Let S(L,P)=l=1Lp=1PF(l,p). Find S(10000,1000)mod1000000007.


Thanks to baihacker for the idea.