莫比乌斯反演的题目大多可以使用莫比乌斯函数性质求出
莫比乌斯函数性质就是
\([n=1]=\displaystyle \sum _{i|n}\mu(i)\)
比如说你要求
\(\displaystyle \sum _{i=1}^{n}\displaystyle \sum _{j=1}^{m}gcd(i,j)\)
其中\(n<m\)
你可以先枚举gcd
\(\displaystyle \sum _{d=1}^{n}d\displaystyle \sum _{i=1}^{n}\displaystyle \sum _{j=1}^{m}[gcd(i,j)=d]\)
考虑将\(i=i*d,j=j*d\)这里说的不详细可以看下面
\(\displaystyle \sum _{d=1}^{n}d\displaystyle \sum _{i=1}^{\lfloor \frac{n}{d}\rfloor}\displaystyle \sum _{j=1}^{\lfloor \frac{m}{d}\rfloor}[gcd(i,j)=d]\)
由莫比乌斯函数性质,原式可化为
\(\displaystyle \sum _{d=1}^{n}d\displaystyle \sum _{i=1}^{\lfloor \frac{n}{d}\rfloor}\displaystyle \sum _{j=1}^{\lfloor \frac{m}{d}\rfloor}\displaystyle \sum _{t|gcd(i,j)}\mu(t)\)
更换枚举项顺序
\(\displaystyle \sum _{d=1}^{n}d\displaystyle \sum _{t=1}^{\lfloor \frac{n}{d}\rfloor}\mu(t) \displaystyle \sum _{i=1}^{\lfloor \frac{n}{d}\rfloor}\displaystyle \sum _{j=1}^{\lfloor \frac{m}{d}\rfloor}[t|i]*[t|j]\)
看后面那个鬼
我们设\(i=s*t,j=r*t\),此时因为\(i\leq n\) ,\(s*t\leq n\),\(s\leq \frac {n}{t}\)
此处因为\(t\nmid i\) 贡献为零,我们只考虑整除情况
\(\displaystyle \sum _{d=1}^{n}d\displaystyle \sum _{t=1}^{\lfloor \frac{n}{d}\rfloor}\mu(t)\displaystyle \sum _{s=1}^{\lfloor \frac{n}{td}\rfloor}\displaystyle \sum _{r=1}^{\lfloor \frac{m}{td}\rfloor}1\)
后面\(\displaystyle \sum _{s=1}^{\lfloor \frac{n}{td}\rfloor}\displaystyle \sum _{r=1}^{\lfloor \frac{m}{td}\rfloor}1=\displaystyle \sum _{s=1}^{\lfloor \frac{n}{td}\rfloor}1\displaystyle \sum _{r=1}^{\lfloor \frac{m}{td}\rfloor}1=\displaystyle \sum _{s=1}^{\lfloor \frac{n}{td}\rfloor}1*\displaystyle \sum _{r=1}^{\lfloor \frac{m}{td}\rfloor}1=\lfloor\frac{n}{td}\rfloor\lfloor \frac{m}{td}\rfloor\)
原式等于
\(\displaystyle \sum _{d=1}^{n}d\displaystyle \sum _{t=1}^{\lfloor \frac{n}{d}\rfloor}\mu(t)\lfloor\frac{n}{td}\rfloor\) \(\lfloor \frac{m}{td}\rfloor\)
看起来不够简洁,莫反题有一种套路
就是当\(\displaystyle \sum _{d=1}^{n}f(d)\displaystyle \sum _{t=1}^{\lfloor \frac{n}{d}\rfloor}h(t)\)时\(f,h\)为两个关于\(d,t\)的函数
我们可以设 \(g=d\times t\)
原式为\(\displaystyle \sum _{g=1}^{n}\sum _{d\mid g} f(d)*h(\frac{g}{d})\)\(=\)\(\displaystyle \sum _{g=1}^{n}\sum _{t\mid g} h(t)*f(\frac{g}{t})\)
\(\displaystyle \sum _{g=1}^{n} \lfloor\frac{n}{g}\rfloor\lfloor \frac{m}{g}\rfloor\sum _{d\mid g} d*\mu(\frac{g}{d})\)
后面那个相当于\(id*\mu\) 其中\(*\)是迪利克雷卷积
迪利克雷卷积常见结论\(id*\mu=\varphi\)
原式为\(\displaystyle \sum _{g=1}^{n} \lfloor\frac{n}{g}\rfloor\lfloor \frac{m}{g}\rfloor\varphi(g)\)
处理完\(\varphi\)前缀和后,剩下的就是整除分块了
来源:https://www.cnblogs.com/Phoenix41/p/12390976.html