类欧几里得算法学习笔记

荒凉一梦 提交于 2019-12-06 12:49:13

如何求\(\sum_{i=0}^ni^{k1}\lfloor\frac{ai+b}{c}\rfloor^{k2}\)\((1\leqslant n,a,b,c\leqslant10^9,k1+k2\leqslant 10)\)

\(f(n,a,b,c)[k1][k2]\)表示原式的值,则:

\(a\geqslant c\),设\(a=pc+q(0\leqslant q<c)\),则
\[\begin{align} &\;\;\;\;\;f(n,a,b,c)[k1][k2]\\ &=\sum_{i=0}^ni^{k1}\lfloor\frac{ai+b}{c}\rfloor^{k2}\\ &=\sum_{i=0}^ni^{k1}(pi+\lfloor\frac{qi+b}{c}\rfloor)^{k2}\\ &=\sum_{i=0}^ni^{k1}\sum_{j=0}^{k2}\text{C}_{k2}^jp^ji^j\lfloor\frac{qi+b}{c}\rfloor^{k2-j}\\ &=\sum_{j=0}^{k2}\text{C}_{k2}^jp^j\sum_{i=0}^ni^{k1+j}\lfloor\frac{qi+b}{c}\rfloor^{k2-j}\\ &=\sum_{j=0}^{k2}\text{C}_{k2}^jp^jf(n,q,b,c)[k1+j][k2-j] \end{align}\]
只需递归计算\(f(n,q,b,c)\)\(O(k^3)\)处理即可。
\(b\geqslant c\),设\(b=pc+q(0\leqslant q<c)\),则
\[\begin{align} &\;\;\;\;\;f(n,a,b,c)[k1][k2]\\ &=\sum_{i=0}^ni^{k1}\lfloor\frac{ai+b}{c}\rfloor^{k2}\\ &=\sum_{i=0}^ni^{k1}(p+\lfloor\frac{ai+q}{c}\rfloor)^{k2}\\ &=\sum_{i=0}^ni^{k1}\sum_{j=0}^{k2}\text{C}_{k2}^jp^j\lfloor\frac{ai+q}{c}\rfloor^{k2-j}\\ &=\sum_{j=0}^{k2}\text{C}_{k2}^jp^j\sum_{i=0}^ni^{k1}\lfloor\frac{ai+q}{c}\rfloor^{k2-j}\\ &=\sum_{j=0}^{k2}\text{C}_{k2}^jp^jf(n,a,q,c)[k1][k2-j] \end{align}\]
只需递归计算\(f(n,a,q,c)\)\(O(k^3)\)处理即可。

(to be continued...)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!