《洛谷P3327 [SDOI2015]约数个数和》
题意:求解$ans = \sum_{i = 1}^{n}\sum_{j = 1}^{m}d(ij)$
首先莫比乌斯函数有性质:$d(ij) = \sum_{x | i}^{}\sum_{y | j}^{}|gcd(x,y) == 1|$
那么,我们可以代入得:
$ans = \sum_{i = 1}^{n}\sum_{j = 1}^{m}\sum_{x | i}^{}\sum_{y | j}^{}|gcd(x,y) == 1| = ans = \sum_{i = 1}^{n}\sum_{j = 1}^{m}\sum_{x | i}^{}\sum_{y | j}^{}\sum_{d | gcd(x,y)}^{}\mu (d)$
枚举d得,$ans = \sum_{i = 1}^{n}\sum_{j = 1}^{m}\sum_{x | i}^{}\sum_{y | j}^{}\sum_{d = 1}^{min(n,m)}\mu (d) * |d | gcd(x,y)|$
移项得$ans = \sum_{d = 1}^{min(n,m)}\mu (d) \sum_{i = 1}^{n}\sum_{j = 1}^{m}\sum_{x | i}^{}\sum_{y | j}^{} * |d | gcd(x,y)|$
再化简得