UOJ450 复读机

题意

kk 种球,每种个数必须是 dd 的倍数,共 nn 个,求排成一行的方案数.

n109,k5×105,d3n\le 10^9, k\le 5\times10^5, d\le 3,答案对 1949100119491001 取模.

题解

Ans=n!i10,di11i1!0i2,di21i2!0ik,dik1ik!=[xn]n!(i0,dixii!)k \begin{aligned} \text{Ans}&=n!\sum_{i_1 \ge 0,d\mid i_1}\frac{1}{i_1!}\sum_{0\le i_2,d\mid i_2}\frac{1}{i_2!}\cdots\sum_{0\le i_k,d\mid i_k}\frac{1}{i_k!}\\ &=[x^n]n!(\sum_{i\ge 0,d\mid i}\frac{x^i}{i!})^k\\ \end{aligned}

i0,dixii!=i0xii!1d0j<dωdji单位根反演=1d0j<di0(xωdj)ii!=1d0j<dexωdj泰勒展开 \begin{aligned} \sum_{i\ge 0,d\mid i}\frac{x^i}{i!}&=\sum_{i\ge 0}\frac{x^i}{i!}\frac{1}{d}\sum_{0\le j < d}{\omega_d^j}^i& \text{单位根反演}\\ &=\frac{1}{d}\sum_{0\le j < d}\sum_{i\ge 0}\frac{(x\omega_d^j)^i}{i!}\\ &=\frac{1}{d}\sum_{0\le j < d}e^{x\omega_d^j}& \text{泰勒展开}\\ \end{aligned}

d=2d=2

i0,dixii!=1d0j<dexωdj=ex+ex2(i0,dixii!)k=n!(ex+ex2)k=12k0ik(ki)eixex(ki)二项式定理=12k0ik(ki)e2ixkxAns=[xn]n!(i0,dixii!)k=n!2k0ik(ki)[xn]e2ixkx=n!2k0ik(ki)(2ik)nn!泰勒展开=12k0ik(ki)(2ik)n \begin{aligned} \sum_{i\ge 0,d\mid i}\frac{x^i}{i!}&=\frac{1}{d}\sum_{0\le j < d}e^{x\omega_d^j}\\ &=\frac{e^x+e^{-x}}{2}\\ (\sum_{i\ge 0,d\mid i}\frac{x^i}{i!})^k&=n!(\frac{e^x+e^{-x}}{2})^k\\ &=\frac{1}{2^k}\sum_{0\le i\le k}\begin{pmatrix}k\\i\end{pmatrix}e^{ix}e^{-x(k-i)} & \text{二项式定理}\\ &=\frac{1}{2^k}\sum_{0\le i\le k}\begin{pmatrix}k\\i\end{pmatrix}e^{2ix-kx}\\ \text{Ans}&=[x^n]n!(\sum_{i\ge 0,d\mid i}\frac{x^i}{i!})^k\\ &=\frac{n!}{2^k}\sum_{0\le i\le k}\begin{pmatrix}k\\i\end{pmatrix}[x^n]e^{2ix-kx}\\ &=\frac{n!}{2^k}\sum_{0\le i\le k}\begin{pmatrix}k\\i\end{pmatrix}\frac{(2i-k)^n}{n!} & \text{泰勒展开}\\ &=\frac{1}{2^k}\sum_{0\le i\le k}\begin{pmatrix}k\\i\end{pmatrix}(2i-k)^n \end{aligned} d=3d=3i0,dixii!=1d0j<dexωdj=ex+eω3x+eω32x3(i0,dixii!)k=n!(ex+eω3x+eω32x3)k=13k0ik(ki)0jki(kij)eixejω3xe(kij)ω32x多项式定理=13k0ik0jki(ki)(kij)eix+jω3x+kω32xiω32xjω32xAns=[xn]n!(i0,dixii!)k=n!3k0ik0jki(ki)(kij)[xn]eix+jω3x+kω32xiω32xjω32x=n!3k0ik0jki(ki)(kij)(i+jω3+kω32iω32jω32)nn!泰勒展开=13k0ik0jki(ki)(kij)(i+jω3+kω32iω32jω32)n \begin{aligned} \sum_{i\ge 0,d\mid i}\frac{x^i}{i!}&=\frac{1}{d}\sum_{0\le j < d}e^{x\omega_d^j}\\ &=\frac{e^x+e^{\omega_3x}+e^{\omega_3^2x}}{3}\\ (\sum_{i\ge 0,d\mid i}\frac{x^i}{i!})^k&=n!(\frac{e^x+e^{\omega_3x}+e^{\omega_3^2x}}{3})^k\\ &=\frac{1}{3^k}\sum_{0\le i\le k}\begin{pmatrix}k\\i\end{pmatrix}\sum_{0\le j\le k-i}\begin{pmatrix}k-i\\j\end{pmatrix}e^{ix}e^{j\omega_3x}e^{(k-i-j)\omega_3^2x} & \text{多项式定理}\\ &=\frac{1}{3^k}\sum_{0\le i\le k}\sum_{0\le j\le k-i}\begin{pmatrix}k\\i\end{pmatrix}\begin{pmatrix}k-i\\j\end{pmatrix}e^{ix+j\omega_3x+k\omega_3^2x-i\omega_3^2x-j\omega_3^2x}\\ \text{Ans}&=[x^n]n!(\sum_{i\ge 0,d\mid i}\frac{x^i}{i!})^k\\ &=\frac{n!}{3^k}\sum_{0\le i\le k}\sum_{0\le j\le k-i}\begin{pmatrix}k\\i\end{pmatrix}\begin{pmatrix}k-i\\j\end{pmatrix}[x^n]e^{ix+j\omega_3x+k\omega_3^2x-i\omega_3^2x-j\omega_3^2x}\\ &=\frac{n!}{3^k}\sum_{0\le i\le k}\sum_{0\le j\le k-i}\begin{pmatrix}k\\i\end{pmatrix}\begin{pmatrix}k-i\\j\end{pmatrix}\frac{(i+j\omega_3+k\omega_3^2-i\omega_3^2-j\omega_3^2)^n}{n!} & \text{泰勒展开}\\ &=\frac{1}{3^k}\sum_{0\le i\le k}\sum_{0\le j\le k-i}\begin{pmatrix}k\\i\end{pmatrix}\begin{pmatrix}k-i\\j\end{pmatrix}(i+j\omega_3+k\omega_3^2-i\omega_3^2-j\omega_3^2)^n \end{aligned}

作者

Fisher Cai

发布于

2021-10-16

更新于

2025-07-22

许可协议

评论

Your browser is out-of-date!

Update your browser to view this website correctly.&npsb;Update my browser now

×