【题解】P12072 [THOI 2014] 超立方体
https://www.luogu.com.cn/problem/P12072
考虑 \(s\to t\) 的贡献:考虑每次增加或减少一个 bit,设这个方案数是 \(f\),贡献系数是 \(f_{|s\oplus t|}\)。\(f\) 可以用矩阵快速幂求出来。
\[\begin{aligned}
ans_s&=\sum_{t} a_t f_{|s\oplus t|} \\
&=\sum_{x} f_{|x|} \sum_{s\oplus t=x} a_t \\
&=\sum_{x} f_{|x|} \mathtt{IFWT}(\mathtt{FWT}(x^s)\times \mathtt{FWT}(a))_x \\
&=\sum_{x} f_{|x|} \frac{1}{n}\sum_{i} (-1)^{|i\& x|}(-1)^{|i\&s|}\mathtt{FWT}(a)_i \\
&= \frac{1}{n}\sum_{i} (-1)^{|i\&s|}\mathtt{FWT}(a)_i\sum_{x} f_{|x|}(-1)^{|i\& x|} \\
\end{aligned}
\]
先处理后面那个式子,然后点乘 \(\mathtt{FWT}(a)\),再做 IFWT。
注意到没有逆元,但是由于最后一定是 \(n\) 的倍数所以可以 \(\bmod (nP)\) 再除以 \(n\)。
浙公网安备 33010602011771号