菜鸡滚回石家庄了233
Problem B: 求和
题解&反思:
好久没写反演了真刺激
大力推公式就好咯
\[
\sum_{i=1}^{n}\sum_{j=1}^{i}\sum_{k=1}^{i}gcd(i,j,k)
\]
\[
=\sum_{i=1}^{n}\sum_{d|i}d\sum_{j=1}^{i}\sum_{k=1}^{i}[gcd(i,j,k)==d]
\]
\[
=\sum_{i=1}^{n}\sum_{d|i}d\sum_{j=1}^{\left \lfloor \frac{i}{d} \right \rfloor}\sum_{k=1}^{\left \lfloor \frac{i}{d} \right \rfloor}[gcd(\frac{i}{d},j,k)==1]
\]
\[
=\sum_{i=1}^{n}\sum_{d|i}d\sum_{j=1}^{\left \lfloor \frac{i}{d} \right \rfloor}\sum_{k=1}^{\left \lfloor \frac{i}{d} \right \rfloor}\sum_{e|\frac{i}{d},e|j,e|k}\mu(e)
\]
\[
=\sum_{i=1}^{n}\sum_{e=1}^{i}\mu(e)\sum_{d|i,d|\frac{i}{d}}d\sum_{e|j}\sum_{e|k}
\]
\[
=\sum_{i=1}^{n}\sum_{e=1}^{i}\mu(e)\sum_{d|i,ed|i}d\left \lfloor \frac{i}{de} \right \rfloor^2
\]
\[
设
t=de
\]
\[
=\sum_{i=1}^{n}\sum_{t|i}\sum_{d|t}d\mu(\frac{t}{d})\left \lfloor \frac{i}{t} \right \rfloor^2
\]
\[
=\sum_{i=1}^{n}\sum_{t|i}\varphi(t)\left \lfloor \frac{i}{t} \right \rfloor^2
\]
交换一下(不交换也可以,但是结果的求和项会反过来
\[
=\sum_{i=1}^{n}\sum_{t|i}\varphi(\left \lfloor \frac{i}{t} \right \rfloor)t^2
\]
\[
=\sum_{t=1}^{n}t^2\sum_{t|i}\varphi(\left \lfloor \frac{i}{t} \right \rfloor)
\]
\[
=\sum_{t=1}^{n}t^2\sum_{i=1}^{\left \lfloor \frac{n}{t} \right \rfloor}\varphi(t)
\]
……就这样,中间没有交换结果反过来了,还以为发现了什么惊天大秘密(像个智障
原文地址:https://www.cnblogs.com/lokiii/p/8597231.html