# 定义

$S_k(n) = \sum_{i=1}^{n}i^k$

# 性质

$$S_k(n)$$ 为关于 $$n$$$$k+1$$ 次多项式。

$$k=0$$ 时，$$S_k(n) = n$$，结论成立。
$$k=d$$ 时：

\begin{aligned} &(i+1)^{d+1} - i^{d+1}\\ = &\sum_{j=0}^{d+1}\left(\begin{matrix}d+1\\j\end{matrix}\right)i^j - i^{d+1}\\ = &\sum_{j=0}^{d}\left(\begin{matrix}d+1\\j\end{matrix}\right)i^j \end{aligned}

$$(i+1)^{d+1} - i^{d+1}$$ 求和，有：

\begin{aligned}&\sum_{i=1}^{n}\left\{(i+1)^{d+1} - i^{d+1}\right\}\\=&\sum_{i=1}^{n}\sum_{j=0}^{d}\left(\begin{matrix}d+1\\j\end{matrix}\right)i^j\end{aligned}

\begin{aligned}&\sum_{i=1}^{n}\sum_{j=0}^{d}\left(\begin{matrix}d+1\\j\end{matrix}\right)i^j\\=&\sum_{j=0}^{d}\left(\begin{matrix}d+1\\j\end{matrix}\right)\sum_{i=1}^{n}i^j\\=&\sum_{j=0}^{d}\left(\begin{matrix}d+1\\j\end{matrix}\right)S_j(n)\end{aligned}

$(n+1)^{d+1} - 1 = \sum_{j=0}^{d}\left(\begin{matrix}d+1\\j\end{matrix}\right)S_j(n)$

$\left(\begin{matrix}d+1\\d\end{matrix}\right)S_d(n) = (n+1)^{d+1} -\sum_{j=0}^{d-1}\left\{\left(\begin{matrix}d+1\\j\end{matrix}\right)S_j(n)\right\} - 1$

$S_d(n) = \dfrac{1}{d+1}\left\{\sum_{j=0}^{d+1}n^j -\sum_{j=0}^{d-1}\left\{\left(\begin{matrix}d+1\\j\end{matrix}\right)S_j(n)\right\} - 1\right\}$

# 差分法

$S_k(n) = \dfrac{1}{k+1}\left\{\sum_{j=0}^{k+1}n^j -\sum_{j=0}^{k-1}\left\{\left(\begin{matrix}k+1\\j\end{matrix}\right)S_j(n)\right\} - 1\right\}$

# 拉格朗日插值

$S_k(n)= \sum_{i=1}^{k+2}S_k(i)\prod_{i\not ={j}}\dfrac{n-j}{i-j}$

$S_k(n)= \sum_{i=1}^{k+2}S_k(i)\dfrac{\prod\limits_{i\not ={j}}{(n-j)}}{\prod\limits_{i\not ={j}}(i-j)}$

\begin{aligned} &\dfrac{1}{\prod\limits_{i\not ={j}}(i-j)}\\ = &\dfrac{1}{i(i-1)(i-2) \dots 1 \times(-1) \dots (k+2-i-1)(k+2-i)}\\=&(-1)^{k+2-i}\dfrac{1}{i! (k+2-i)!} \end{aligned}

\begin{aligned} &\prod\limits_{i\not ={j}}{(n-j)}\\ =& n(n-1) \dots (n-(i-1))(n-(i+1))\dots (n-(k+2))\\ =&(\prod_{j=1}^{i-1}(n-j)) (\prod_{j=i+1}^{k+2}(n-j))& \end{aligned}

$S_k(n)= \sum_{i=1}^{k+2}(-1)^{k+2-i}S_k(i)\dfrac{(\prod\limits_{j=1}^{i-1}(n-j)) (\prod\limits_{j=i+1}^{k+2}(n-j))}{i! (k+2-i)!}$

## 复杂度

$$O(k \log k)$$ 处理 $$k+2$$ 个连续点值。
$$O(n)$$ 预处理前/后 缀积，阶乘。

# 第一类斯特林数

$S_k(n) = \dfrac{(n+1)^{\underline{k+1}}}{k+1} -\sum_{i=0}^{k-1} \cdot {\displaystyle \left[{\begin{matrix}k\\i\end{matrix}}\right]\,} \cdot S_i(n)$

## 引理 1

$x^{\underline{n}} = (-1)^{n}(-x)^{\overline{n}}$

$x^{\overline{n}} = (-1)^{n}(-x)^{\underline{n}}$

\begin{aligned} x^{\underline{n}} =& \prod_{i=0}^{n-1}(x-i)\\ =& (-1)^n \prod_{i=0}^{n-1}-(x-i)\\ =& (-1)^n \prod_{i=0}^{n-1}(-x + i)\\ =& (-1)^n (-x)^{\overline{n}} \end{aligned}

## 引理 2

$n^{\underline{k}} = \sum_{i=0}^{k}(-1)^{k-i}{\displaystyle \left[{\begin{matrix}k\\i\end{matrix}}\right]}n^{i}$

$n^{\overline{k}} = \sum_{i=0}^{k}{\begin{bmatrix}k\\i\end{bmatrix}}n^{i}$

\begin{aligned} n^{\overline{k}} =& \sum_{i=0}^{k}{\begin{bmatrix}k\\i\end{bmatrix}}n^{i}\\ (-1)^k (-n)^{\underline{k}}=& \sum_{i=0}^{k}{\begin{bmatrix}k\\i\end{bmatrix}}n^{i} \end{aligned}

\begin{aligned} (-1)^k (-n)^{\underline{k}}=& \sum_{i=0}^{k}{\begin{bmatrix}k\\i\end{bmatrix}}n^{i}\\ (-n)^{\underline{k}}=& \sum_{i=0}^{k}{\begin{bmatrix}k\\i\end{bmatrix}}(-1)^k n^{i} \end{aligned}

\begin{aligned} (-n)^{\underline{k}}=& \sum_{i=0}^{k}{\begin{bmatrix}k\\i\end{bmatrix}}(-1)^k n^{i}\\ (-n)^{\underline{k}}=& \sum_{i=0}^{k}(-1)^{k-i}{\begin{bmatrix}k\\i\end{bmatrix}} (-n)^{i}\\ n^{\underline{k}}=& \sum_{i=0}^{k}(-1)^{k-i}{\begin{bmatrix}k\\i\end{bmatrix}} n^{i} \end{aligned}

## 证明

$n^k = n^{\underline{k}} - \sum\limits_{i=0}^{k-1}(-1)^{k-i}{\displaystyle \left[{\begin{matrix}k\\i\end{matrix}}\right]}n^{i}$

\begin{aligned} S_k(n) &= \sum_{i=1}^{n}i^k \\ &= \sum_{i=1}^{n}\left\{{i^{\underline{k}}-\sum_{j=0}^{k-1}(-1)^{k-j}{\displaystyle \left[\begin{matrix}k\\j\end{matrix}\right]}i^j}\right\} \end{aligned}

\begin{aligned} &\sum\limits_{i=1}^{n}i^{\underline{k}}\\ =&k!\sum_{i=1}^{n}\dfrac{i^{\underline{k}}}{k!}\\ =&k!\sum_{i=1}^{n}{\displaystyle\left(\begin{matrix}i\\k\end{matrix}\right)}\\ =&k!{\displaystyle\left(\begin{matrix}n+1\\k+1\end{matrix}\right)}\\ =&\dfrac{(n+1)^{\underline{k+1}}}{k+1} \end{aligned}

\begin{aligned} &\sum_{j=0}^{k-1}(-1)^{k-j}{\displaystyle \left[\begin{matrix}k\\j\end{matrix}\right]}\sum_{1}^{n}i^j \\= &\sum_{i=0}^{k-1} \cdot {\displaystyle \left[{\begin{matrix}k\\i\end{matrix}}\right]\,} \cdot S_i(n) \end{aligned}

# 伯努利数

$$e$$$$\infin$$ 是个什么玩意
？多项式求逆

# 题目

CF622F The Sum of the k-th Powers
$$n\le 10^9, k\le 10^6$$

# 写在最后

？我也不知道为什么叫差分法

63 级学弟学妹来啦！

posted @ 2020-08-03 21:06  Luckyblock  阅读(511)  评论(0编辑  收藏  举报