LOJ6539 做题记录
推式子题,Trick 有些巧妙。
先来解决 \((i,j)\),显然进行莫反:
\[\begin{aligned}
&\sum_{i=1}^n\sum_{j=1}^n(a_i,a_j)(i,j)\\
&=\sum_{d=1}^nd\sum_{i=1}^{\lfloor\frac{n}{d}\rfloor}\sum_{j=1}^{\lfloor\frac{n}{d}\rfloor}(a_{id},a_{jd})[(i,j)=1]\\
&=\sum_{d=1}^nd\sum_{x=1}^{\lfloor\frac{n}{d}\rfloor}\mu(x)\sum_{i=1}^{\lfloor\frac{n}{dx}\rfloor}\sum_{j=1}^{\lfloor\frac{n}{dx}\rfloor}(a_{idx},a_{jdx})
\end{aligned}
\]
令 \(f(x)=\sum\limits_{i=1}^{\lfloor\frac{n}{x}\rfloor}\sum\limits_{j=1}^{\lfloor\frac{n}{x}\rfloor}(a_{ix},a_{jx})\)。我们让小于等于 \(n\) 的 \(x\) 的倍数集合为 \(\mathbb{S}_x\)。
于是有:
\[\begin{aligned}
f(x)&=\sum\limits_{i\in\mathbb{S}_x}\sum\limits_{j\in\mathbb{S}_x} (a_i,a_j)\\
&=\sum_{d}\sum_{i\in\mathbb{S}_x}\sum_{j\in\mathbb{S}_x}[(a_i,a_j)=d]
\end{aligned}
\]
发现将 \([(a_i,a_j)=d]\) 转化为 \([(\dfrac{a_i}{d},\dfrac{a_j}{d})=1]\) 之后不好做,于是考虑一种新的转化:转化为 \([\dfrac{(a_i,a_j)}{d}=1]\)。
\[\begin{aligned}
f(x)&=\sum\limits_{i\in\mathbb{S}_x}\sum\limits_{j\in\mathbb{S}_x} (a_i,a_j)\\
&=\sum_{d}d\sum_{i\in\mathbb{S}_x}\sum_{j\in\mathbb{S}_x}[(a_i,a_j)=d]\\
&=\sum_{d}d\sum_{i\in\mathbb{S}_x}\sum_{j\in\mathbb{S}_x}[\frac{(a_i,a_j)}{d}=1]\\
&=\sum_{d}d\sum_{i\in\mathbb{S}_x}\sum_{j\in\mathbb{S}_x}\sum_{q\mid\frac{(a_i,a_j)}{d}}\mu(q)\\
&=\sum_{d}d\sum_{d\mid T}\mu(\dfrac{T}{d})\sum_{i\in\mathbb{S}_x}\sum_{j\in\mathbb{S}_x}[T\mid(a_i,a_j)]\\
&=\sum_{d}d\sum_{d\mid T}\mu(\dfrac{T}{d})(\sum_{i\in\mathbb{S}_x}[T\mid a_i])^2\\
&=\sum_{T}(\color{blue}\sum_{d\mid T}d\cdot\mu(\dfrac{T}{d})\color{black})(\sum_{i\in\mathbb{S}_x}[T\mid a_i])^2\\
&=\sum_{T=1}^n\varphi(T)(\sum_{i\in\mathbb{S}_x}[T\mid a_i])^2
\end{aligned}
\]
其中,我们令 \(T=dq\)。蓝色部分比较巧妙:发现 \(\mu * \text{id}=\varphi\),于是直接替换成 \(\varphi\)。
于是:
\[\begin{aligned}
&\sum_{i=1}^n\sum_{j=1}^n(a_i,a_j)(i,j)\\
&=\sum_{d=1}^n\sum_{i=1}^{\lfloor\frac{n}{d}\rfloor}\sum_{j=1}^{\lfloor\frac{n}{d}\rfloor}(a_{id},a_{jd})[(i,j)=1]\\
&=\sum_{d=1}^n\sum_{x=1}^{\lfloor\frac{n}{d}\rfloor}\mu(x)\sum_{i=1}^{\lfloor\frac{n}{dx}\rfloor}\sum_{j=1}^{\lfloor\frac{n}{dx}\rfloor}(a_{idx},a_{jdx})\\
&=\sum_{d=1}^n\sum_{x=1}^{\lfloor\frac{n}{d}\rfloor}\mu(x)f(dx)
\end{aligned}
\]
做完。

浙公网安备 33010602011771号