← RoseCode

ROSECODE 466

Displacement of permutation

liuguangxi · Math ·

Let p be a permutation of the set {1,2,3,,n}. We call the sum Dk(p)=i=1n|pii|k the total displacement with kth power of p. For example, if p = (4,2,1,3), D1(p)=|41|+|22|+|13|+|34|=6, D2(p)=|41|2+|22|2+|13|2+|34|2=14, D3(p)=|41|3+|22|3+|13|3+|34|3=36.

For any positive integer n, assume every possible permutation p of the set {1,2,3,,n} is uniformly distributed. Let E(n) be the expected value of D1(p)+D2(p)+D3(p). You are given E(2)=3, E(3)=40/3, E(5)=432/5, and all E(n) are rational number. Let F(n) be the numerator of E(n) with E(n) be fraction in lowest terms. So, F(2)=3, F(3)=40, F(5)=432 and so on.

Let S(n)=i=1nF(i). Find S(12345678987654321)mod1000000007.


Thanks to baihacker for the idea.