P5591 小猪佩奇学数学
\[\frac{1}{k}(\sum\limits_{i = 0}^{n} \binom{n}{i} p^i i - \sum\limits_{i = 0}^{n} \binom{n}{i} p^i \sum\limits_{j = 0}^{k - 1} j [k | i - j])
\]
把 \(\frac{1}{k}\) 最后乘上就好了。
\[\sum\limits_{i = 0}^{n} \binom{n}{i} p^i i - \frac{1}{k} \sum\limits_{i = 0}^{n} \binom{n}{i} p^i \sum\limits_{j = 0}^{k - 1} j \sum\limits_{t = 0}^{k - 1} \omega_{k}^{t \times (i - j)}
\]
\[\sum\limits_{i = 0}^{n} \binom{n}{i} p^i i - \frac{1}{k} \sum\limits_{t = 0}^{k - 1} \sum\limits_{j = 0}^{k - 1} j \omega_{k}^{- t \times j} \sum\limits_{i = 0}^{n} \omega_{k}^{i \times t} \binom{n}{i} p^i
\]
分为两部分计算。
第一部分:
\[\sum\limits_{i = 0}^{n} \binom{n}{i} p^i i
\]
\[n \sum\limits_{i = 0}^{n} \binom{n-1}{i-1} p^i
\]
\[n p \sum\limits_{i = 0}^{n-1} \binom{n}{i} p^{i}
\]
\[n p (p + 1)^{n - 1}
\]
第二部分:
\[\sum\limits_{t = 0}^{k - 1} \sum\limits_{j = 0}^{k - 1} j \omega_{k}^{- t \times j} \sum\limits_{i = 0}^{n} \omega_{k}^{i \times t} \binom{n}{i} p^i
\]
\[\sum\limits_{t = 0}^{k - 1} \sum\limits_{j = 0}^{k - 1} j \omega_{k}^{- t \times j} \sum\limits_{i = 0}^{n} \binom{n}{i} (w_{k}^tp)^i
\]
\[\sum\limits_{t = 0}^{k - 1} \sum\limits_{j = 0}^{k - 1} j \omega_{k}^{- t \times j} (w_{k}^tp+1)^n
\]
让 \(f_t = \sum\limits_{j = 0}^{k - 1} j \times \omega_{k}^{- t j}\)
首先如果 \(t | k\),那么 \(\omega_{k}^{t} = 1\),\(f_t = \frac{k (k - 1)}{2}\)
否则 \(f_t = \sum\limits_{j = 0}^{k - 1} \sum\limits_{a = 0}^{j - 1} \omega_{k}^{ - tj}\)
\[\sum\limits_{a = 0}^{k - 1} \sum\limits_{j = a + 1}^{k - 1} \omega_{k}^{ - tj}
\]
\[\sum\limits_{a = 0}^{k - 1} \frac{\omega_k^{- t (a + 1)} - \omega_{k}^{- t k}}{1 - \omega_{k}^{-t}}
\]
\[\frac{1}{1 - \omega_{k}^{-t}} \sum\limits_{a = 0}^{k - 1} \omega_k^{- t (a + 1)} - 1
\]
因为 \(\sum\limits_{a = 0}^{k - 1} \omega_k^{- t (a + 1)} = 0\),因此可以把那个 \(\sum\limits_{a = 0}^{k - 1} \omega_k^{- t (a + 1)}\) 给去掉。
\[\frac{k}{\omega_{k}^{-t} - 1}
\]