近期做题记录

\(CF 1295F\)

划艇。
离散化值域,分成 \(cnt\) 左右个左闭右开区间。设 \(f_{i, j}\) 表示前 \(i\) 个数合法填完,第 \(i\) 个数在第 \(j\) 个区间,\(len_j\) 表示离散化后 \(c_{j+1} - c_j\),也就是第 \(j\) 段的长度。
显然有转移:\(f_{i, j} = \sum_{k = 0}^{i-1} \limits (\sum_{p = j + 1}^{cnt} \limits f_{k, p}) (\prod_{p = k + 1}^i \limits \dfrac{len_j}{r_p - l_p + 1}) (\dfrac{\binom {len_j + i - k - 1}{i - k}}{len_j^{i-k}})\)
简单前缀和甚至直接 \(O(n^4)\) 都可以通过。

\(CF 1716F\)

显然有 \(ans = \sum_{i = 0}^n \limits i^k \binom{n}{i} \lceil \frac{m}{2} \rceil^i (m - \lceil \frac{m}{2} \rceil)^{n-i}\),设 \(p = \lceil \frac{m}{2} \rceil, q = m - \lceil \frac{m}{2} \rceil\)

\[\sum_{i = 0}^n \limits i^k \binom{n}{i} p^i q^{n-i} = \sum_{i = 0}^n \limits \sum_{j=0}^k \limits {k \brace j} \binom i j j! \binom{n}{i} p^i q^{n-i} \\ \sum_{i = 0}^n \limits \sum_{j=0}^k \limits {k \brace j} \binom i j j! \binom{n}{i} p^i q^{n-i} = \sum_{j = 0}^k \limits \sum_{i=j}^n \limits {k \brace j} \binom i j j! \binom{n}{i} p^i q^{n-i} \\ \sum_{j = 0}^k \limits \sum_{i=j}^n \limits {k \brace j} \binom i j j! \binom{n}{i} p^i q^{n-i} = \sum_{j = 0}^k \limits \sum_{i=j}^n \limits {k \brace j} \dfrac{n!(n-j)!}{(n-j)!(n-i)!(i-j)!} p^i q^{n-i} \\ \sum_{j = 0}^k \limits \sum_{i=j}^n \limits {k \brace j} \dfrac{n!(n-j)!}{(n-j)!(n-i)!(i-j)!} p^i q^{n-i} = \sum_{j = 0}^k \limits \sum_{i=j}^n \limits {k \brace j} \dfrac{n!}{(n-j)!} \binom{n-j}{i-j} p^i q^{n-i} \\ \sum_{j = 0}^k \limits \sum_{i=j}^n \limits {k \brace j} \dfrac{n!}{(n-j)!} \binom{n-j}{i-j} p^i q^{n-i} = \sum_{j = 0}^k \limits {k \brace j} \dfrac{n!}{(n-j)!} \sum_{i=j}^n \limits \binom{n-j}{i-j} p^i q^{n-i} \\ \sum_{j = 0}^k \limits {k \brace j} \dfrac{n!}{(n-j)!} \sum_{i=j}^n \limits \binom{n-j}{i-j} p^i q^{n-i} = \sum_{j = 0}^k \limits {k \brace j} \dfrac{n!}{(n-j)!} \sum_{i=0}^{n-j} \limits \binom{n-j}{i} p^{i+j} q^{n-i-j} \\ \sum_{j = 0}^k \limits {k \brace j} \dfrac{n!}{(n-j)!} \sum_{i=0}^{n-j} \limits \binom{n-j}{i} p^{i+j} q^{n-i-j} = \sum_{j = 0}^k \limits {k \brace j} \dfrac{n!}{(n-j)!}q^n \sum_{i=0}^{n-j} \limits\binom{n-j}{i} (\dfrac{p}{q})^{i+j} \\ \sum_{j = 0}^k \limits {k \brace j} \dfrac{n!}{(n-j)!}q^n \sum_{i=0}^{n-j} \limits\binom{n-j}{i} (\dfrac{p}{q})^{i+j} = \sum_{j = 0}^k \limits {k \brace j} \dfrac{n!}{(n-j)!}q^n(\frac{p}{q})^j \sum_{i=0}^{n-j} \limits\binom{n-j}{i} (\dfrac{p}{q})^i \\ \sum_{j = 0}^k \limits {k \brace j} \dfrac{n!}{(n-j)!}q^n(\frac{p}{q})^j \sum_{i=0}^{n-j} \limits\binom{n-j}{i} (\dfrac{p}{q})^i = \sum_{j = 0}^k \limits {k \brace j} \dfrac{n!}{(n-j)!}q^n(\frac{p}{q})^j (1 + \dfrac{p}{q})^{n-j} \]

于是,我们 \(O(k^2)\) 预处理斯特林数,预处理一下逆元之类的东西就可以做到 \(O(k)\) 求解。总复杂度 \(O(Tk + k^2)\)

P7116

P3214

P5678

P4484

P4249/CF1264E

P5300

P5303

posted @ 2022-11-04 08:10  David24  阅读(38)  评论(0编辑  收藏  举报