首页 > 代码库 > BZOJ 3561 莫比乌斯反演

BZOJ 3561 莫比乌斯反演

$\Sigma_{i=1}^n\Sigma_{j=1}^mlcm(i,j)^{gcd(i,j)}$
$=\Sigma_{i=1}^n\Sigma_{j=1}^m (\frac{i*j}{gcd(i,j)})^{gcd(i,j)}$
枚举gcd(i,j)=d
$=\Sigma_{d=1}^n\Sigma_{i=1}^{\lfloor \frac{n}{d}\rfloor}\Sigma_{j=1}^{\lfloor \frac{m}{d}\rfloor}(d*i*j)^d*(gcd(i,j)==1)$
$=\Sigma_{d=1}^n\Sigma_{i=1}^{\lfloor \frac{n}{d}\rfloor}\Sigma_{j=1}^{\lfloor \frac{m}{d}\rfloor}\Sigma_{k|i且k|j}(d*i*j)^d$
$=\Sigma_{d=1}^nd^d\Sigma_{t=1}^{\lfloor\frac{n}{d}\rfloor}\mu(t)[\Sigma_{i=1}^{\lfloor\frac{n}{dt}\rfloor}(it)^d\Sigma_{j=1}^{\lfloor\frac{m}{d}\rfloor}(jt)^d]$
$=\Sigma_{d=1}^nd^d\Sigma_{t=1}^{\lfloor\frac{n}{d}\rfloor}\mu(t)*t^{2d}[\Sigma_{i=1}^{\lfloor\frac{n}{dt}\rfloor}i^d\Sigma_{j=1}^{\lfloor\frac{m}{dt}\rfloor}j^d]$

BZOJ 3561 莫比乌斯反演