LUOGU P4345 SHOI2015超能粒子炮·改题解

f ( n , k ) = ∑ i = 0 k C n i % p f(n,k)=\sum_{i=0}^kC_n^i\%p f(n,k)=i=0kCni%p
f ( n , k ) = ∑ i = 0 k C n p i p C n % p i % p % p f(n,k)=\sum_{i=0}^kC_{\frac{n}{p}}^{\frac{i}{p}}C_{n\%p}^{i\%p}\%p f(n,k)=i=0kCpnpiCn%pi%p%p
= ( ( ∑ i = 0 k p − 1 C n p i ∑ j = 0 p − 1 C n % p j ) + ( C n p k p ∑ i = 0 k % p C n % p i ) ) % p =((\sum_{i=0}^{\frac{k}{p}-1}C_{\frac{n}{p}}^i\sum_{j=0}^{p-1}C_{n\%p}^j)+(C_{\frac{n}{p}}^{\frac{k}{p}}\sum_{i=0}^{k\%p}C_{n\%p}^{i}))\%p =((i=0pk1Cpnij=0p1Cn%pj)+(Cpnpki=0k%pCn%pi))%p
= ( f ( n p , k p − 1 ) f ( n % p , p − 1 ) + C n p k p f ( n % p , k % p ) ) % p =(f(\frac{n}{p},\frac{k}{p}-1)f(n\%p,p-1)+C_{\frac{n}{p}}^{\frac{k}{p}}f(n\%p,k\%p))\%p =(f(pn,pk1)f(n%p,p1)+Cpnpkf(n%p,k%p))%p

你可能感兴趣的:(LUOGU P4345 SHOI2015超能粒子炮·改题解)