?
_IceCream_
·
·
个人记录
\mu^2(n) 前缀和
先来证一个神秘的东西:
\mu^2(n) = \sum_{d^2 \mid n} \mu(d)
n 无平方质因子
若 n 没有平方质因子,则不难发现,满足条件的只有 d = 1,则 \mu^2(n) = 1 = \mu(1) 等式成立。
n 有平方质因子
若 n 有平方质因子,设其为 p,也就是 p^2 \mid n。将满足条件的 d 写成集合就是 D = \{d \mid d \ge 1, d^2 \mid n\}。
假设有这个因子,由于 $\mu (pd) = \mu(p)\mu(d) = -\mu(d)$,可以发现两种两两抵消了。而如果 $p^2 \mid d$,则 $\mu(d) = 0$,不影响加和,所以我们又回到了第一种情况。
好的,我们成功证明了这个神秘的式子,接下来给它套前缀和里面。
$$S(n) = \sum_{i = 1}^n \sum_{d^2 \mid i} \mu (d) \\ = \sum_{d=1}^{\lfloor \sqrt n \rfloor} \mu (d) \lfloor \dfrac{n}{d^2} \rfloor$$
我们可以 $O(\sqrt n)$ 实现这玩意了。
关联题目:P4318
## 广义矩阵乘法
这里列举几个,形式如 $C_{i,j} = \bigoplus _k ({A_{i,k} \bigotimes B_{k,j}})$。
满足条件当且仅当 $\oplus$ 满足交换律和结合律,且 $\otimes$ 对 $\oplus$ 满足左右分配律。
* $\oplus$ 为 $\min / \max$,$\otimes$ 为 $+$;
* $\oplus$ 为逻辑或,$\otimes$ 为逻辑与;
* $\oplus$ 为 $\min$,$\otimes$ 为 $\max$;
* $\oplus$ 为 $\max$,$\otimes$ 为 $\min$;
* $\oplus$ 为 $\max$,$\otimes$ 为 $\times$;
* $\oplus$ 为集合并,$\otimes$ 为字符串连接;