[BJOI2019]勘破神机

[BJOI2019]勘破神机

m = 2

\[f[n] = f[n - 1] + f[n - 2]\\ ans = \sum_{i = l}^r(\frac{f[i]}{k})\\ (\frac{f[i]}{k}) = \frac{f[i]^{\underline{k}}}{k!} = \frac{1}{k!}\sum_{j = 0}^k(-1)^{k - j}s(k , j)f[i]^j\\ ans = \frac{1}{k!} * (-1)^k\sum_{j = 0}^k(-1)^{j}s(k , j)\ \ \ \sum_{i = l}^rf[i]^j\\ 直接处理一下前n项斐波拉契数列的和\\ \sum_{i = 1}^nf[i]^k = (\frac{1}{\sqrt 5}(\frac{1 + \sqrt 5}{2}) ^ {n} - \frac{1}{\sqrt 5}(\frac{1 - \sqrt 5}{2}) ^ {n}) ^ k\\ A = \frac{1}{\sqrt 5} , B = -\frac{1}{\sqrt 5} , x = \frac{1 + \sqrt 5}{2} , y = \frac{1 - \sqrt 5}{2}\\ \sum_{i = 1}^nf[i]^k = \sum_{i = 1}^n(Ax^i + By^i) ^ k = \sum_{j = 0}^ k (\frac{k}{j}) A^jB^{k-j}(\sum_{i = 1}^n(x^{j}y^{(k-j)})^i) \\ 后面一段是一个等比,前面直接O(k)计算一下就好了,最后回带,复杂度就是O(k^2)足以通过本题 \]

m = 3的情况同理

解决本题还需要扩展数系....

(早读写写水题真开心)

上一篇:MySql数据表元数据


下一篇:socket 套接字编程