例题
C. DZY Loves Math IV
求$sumlimits_{i=1}^nsumlimits_{j=1}^mphi(ij)$
开始吧!
设gr=n
$g=prodlimits_{pin n}p$
$gcd=gcd(n,i)$
$phi(gi)=gcd*phi(frac{gi}{gcd})=gcd*phi(frac{g}{gcd})*phi(i)$
$sumlimits_{i=1}^nsumlimits_{j=1}^mphi(ij)$
$=sumlimits_{i=1}^nS(i,m)$
$S(n,m)=sumlimits_{i=1}^mphi(ni)$
$=rsumlimits_{i=1}^mgcd*phi(frac{g}{gcd})phi(i)$
$=rsumlimits_{i=1}^msumlimits_{d|gcd}phi(d)phi(frac{g}{gcd})phi(i)$
$=rsumlimits_{i=1}^msumlimits_{d|gcd}phi(frac{g}{frac{gcd}{d}})phi(i)$
$=rsumlimits_{i=1}^msumlimits_{d|gcd}phi(frac{g}{d})phi(i)$
$=rsumlimits_{d|g}phi(frac{g}{d})sumlimits_{i=1}^{frac{m}{d}} phi(di)$
$=rsumlimits_{d|g}phi(frac{g}{d})S(d,frac{m}{d})$
递归形式了,复杂度与质因子个数有关。