光速幂小记
只针对单个底数。如果是多个底数可以做到 \(\mathcal{O}(mod\sqrt{mod})\)。
\(\huge{a^n = a^{b^{\lfloor \frac{n}{b}\rfloor} + a^{n \bmod b}}}\)
取 \(b = \sqrt{n}\),做到 \(\mathcal{O}(\sqrt{n}) \sim \mathcal{O}(1)\)。
P5110 首先用特征多项式/GF/待定系数法求出通项公式,然后二次剩余把根号弄掉,然后光速幂。
(这么简单还单开一章,fw。)

浙公网安备 33010602011771号