The Stirling numbers of the first kind [nk]left[{n atop k}right][kn] are defined such that the number of permutations ofnnn elements which contain exactlykkk permutation cycles . The well known recurrence relation is defined as follows: for k>0k>0k>0,with the initial conditions for n>0n > 0n>0. Roundgod is now solving an interesting task, which gives four integers n,l,rn,l,rn,l,r and ppp, and asks the value of modpdisplaystyle left bmod pmodp whereppp is prime. SeemsRoundgod comes up with the main idea in only one minute. Can you be faster?
The Stirling numbers of the first kind [nk]left[{n atop k}right][kn] are defined such that the number of permutations of nnn elements which contain exactly kkk permutation cycles (with cycles in opposite directions counted as distinct). The well known recurrence relation is defined as follows: for k>0k>0k>0,with the initial conditions for n>0n > 0n>0. Roundgod is now solving an interesting task, which gives four integers n,l,rn,l,rn,l,r and ppp, and asks the value of (∑k=lr[nk]) mod pdisplaystyle left(sum_{k=l}^{r}left[{n atop k}right] right) bmod p(k=l∑r[kn])modp where ppp is prime. Seems Roundgod comes up with the main idea in only one minute. Can you be faster?