随笔分类 - 多项式 FFT/NTT
摘要:洛谷传送门 AtCoder 传送门 首先做一些初步的观察:A 和 B 的解法是对称的,所以 A 对的方案数等于 B 对的方案数。同时若 A 和 B 同时对则每个置换环环长为 \(1\),方案数为 \(n!\)。 所以,若设 A 对的方案数为 \(x\),那么答案为 \(n!^2 - (x - n!)
阅读全文
摘要:洛谷传送门 所求即为: \[\begin{aligned} f_t & = \sum\limits_{m = 0}^L \binom{L}{m} A^m [k \mid m - t] \\ & = \frac{1}{k} \sum\limits_{m = 0}^L \binom{L}{m} A^m
阅读全文
摘要:Bluestein's Algorithm 用于当不是 \(2\) 的整数次幂时对多项式的 (I)DFT。 考虑现在要求: \[f_m = \sum\limits_{k = 0}^{n - 1} a_k w^{mk} \]Bluestein 的核心思想在于拆 \(mk\)。不难证明 \(mk = \
阅读全文
摘要:求逆 考虑倍增。 若已经求出 \(A \times B' \equiv 1 \pmod {x^n}\),我们希望求出 \(B\) 使得 \(A \times B \equiv 1 \pmod {x^{2n}}\)。 有: \[B - B' \equiv 0 \pmod {x^n} \]\[(B -
阅读全文
摘要:洛谷传送门 CF 传送门 首先设 \(a_i = \max\limits_{j = 1}^i p_j\),\(b_i = \max\limits_{j = 1}^i q_j\)。 直接容斥,钦定有多少值不同的 \(a_i\) 使得 \(a_i = b_i\)。然后再把钦定的每种值转化成每种值第一次使
阅读全文
摘要:考虑如下卷积: \[f_i = \sum\limits_{j = 1}^{i - 1} f_j f_{i - j} \]仍然可以 cdq 分治计算。 考虑当前在 \([l, r]\),希望计算 \([l, mid]\) 贡献到 \([mid + 1, r]\)。若 \(r - l < l\) 那么
阅读全文
摘要:洛谷传送门 AtCoder 传送门 和 CF1010F Tree 基本一致。 考虑经典树形背包,设 \(f_{u, i}\) 为 \(u\) 子树内选了 \(i\) 个点的方案数。初始有 \(f_{u, 0} = 1\)。每次考虑合并儿子 \(v\),有转移: \[f_{u, i + j} \get
阅读全文
摘要:洛谷传送门 CF 传送门 educational 的。另一道类似的题是 [ABC269Ex] Antichain。 考虑令 \(b_u = a_u - \sum\limits_{v \in son_u} a_v\)。那么 \(\sum\limits_{i = 1}^n b_i = a_1 = x\)
阅读全文
摘要:洛谷传送门 AtCoder 传送门 设数字 \(i\) 第一次拿到的时间为 \(t_i\),所求即为 \(E(\max\limits_{i = 1}^m t_i)\)。 施 min-max 容斥,有: \[\begin{aligned}E(\max\limits_{i = 1}^m t_i) & =
阅读全文
摘要:洛谷传送门 CF 传送门 考虑若确定了所有 \(c_s\),如何计算集合最大大小。 下文令原题面中的 \(f\) 为 \(m\)。 发现我们可以类似倒推地确定。比如若 \(n = 3\),\(c_{00} = \min(c_{000}, c_{001})\),\(c_{01} = \min(c_{0
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/CF960G "洛谷传送门") [CF 传送门](https://codeforces.com/problemset/problem/960/G "CF 传送门") 发现设排列最大值位置为 $i$,那么 $[1, i]
阅读全文
摘要:洛谷传送门 感觉跟 CF Gym 102978H Harsh Comments 很像。 考虑容斥,钦定 \(S \subseteq [2, n]\) 中的人比 \(1\) 后死。设 \(P(S)\) 为 \(S\) 中的人比 \(1\) 后死的概率,那么答案为: \[ans = \sum\limit
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/P6667 "洛谷传送门") 点值不好搞。考虑把它搞成系数一类的东西。 由二项式反演,$f(x) = \sum\limits_{i = 0}^x \binom{x}{i} b_i \Leftrightarrow b_i
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/AT_abc309_h "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/abc309/tasks/abc309_h "AtCoder 传送门") 挺妙的题。 考虑
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/AT_arc153_e "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/arc153/tasks/arc153_e "AtCoder 传送门") 我们考虑给定 $X
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/AT_abc307_h "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/abc307/tasks/abc307_h "AtCoder 传送门") 一开始看错题了,看
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/AT_abc281_h "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/abc281/tasks/abc281_h "AtCoder 传送门") 考虑设 $f_i$
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/AT_abc247_h "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/abc247/tasks/abc247_h "AtCoder 传送门") 考虑我们如何判定一
阅读全文
摘要:[洛谷传送门](https://www.luogu.com.cn/problem/AT_abc213_h "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/abc213/tasks/abc213_h "AtCoder 传送门") 考虑一个朴素 dp
阅读全文
摘要:洛谷传送门 AtCoder 传送门 好题。 这种题一般可以考虑,观察最优解的性质,对于性质计数。 发现如果 \(n,m\) 均为偶数,可以放满。就是类似这样: #.#.#. .#.#.# #.#.#. .#.#.# 因此答案就是 \(2\)。 如果 \(n,m\) 有一个为偶数,不妨假设 \(n\)
阅读全文

浙公网安备 33010602011771号