洛谷 - P1390 - 公约数的和 - 莫比乌斯反演 - 整除分块
作者:互联网
https://www.luogu.org/problemnew/show/P1390
求 \(\sum\limits_{i=1}^{n}\sum\limits_{j=1}^{m} gcd(i,j) - \sum\limits_{i=1}^{n}i\) .
不会,看题解:
类似求gcd为p的求法:
$ f(n) = \sum\limits_{i=1}^{n}\sum\limits_{j=1}^{m} gcd(i,j) =\sum\limits_{i=1}^{d} d \sum\limits_{i=1}^{n}\sum\limits_{j=1}^{m} [gcd(i,j)==d] $
反演:
$ f(n) = \sum\limits_{i=1}^{d} d \sum\limits_{k=1}^{N} \mu(k) \lfloor\frac{n}{kd}\rfloor \lfloor\frac{m}{kd}\rfloor $
记 \(T=kd\) :
$ f(n) = \sum\limits_{T=1}^{N} \sum\limits_{d|T} d \mu(\frac{T}{d}) \lfloor\frac{n}{T}\rfloor \lfloor\frac{m}{T}\rfloor $
提出 \(T\)
$ f(n) = \sum\limits_{T=1}^{N} \lfloor\frac{n}{T}\rfloor \lfloor\frac{m}{T}\rfloor \sum\limits_{d|T} d \mu(\frac{T}{d}) $
标签:lfloor,frac,gcd,limits,sum,P1390,反演,rfloor,洛谷 来源: https://www.cnblogs.com/Yinku/p/10666135.html