标签:分享 desc sample style hellip 数学 line class sam
1<=N,M,K<=5000000,1<=T<=2000
(建议调一下缩放,博客园的数学公式正常缩放看起来比较恶心……)
$ans=\sum_{i=1}^{n}\sum_{j=1}^{m}\gcd(i,j)^{k}$
$=\sum_{d=1}^{n}d^{k}\sum_{i=1}^{\lfloor \frac{n}{d} \rfloor}\sum_{j=1}^{\lfloor \frac{m}{d} \rfloor}[\gcd(i,j)==1]$
$=\sum_{d=1}^{n} d^{k}\sum_{k=1}^{\lfloor \frac{n}{d} \rfloor}\mu(k)\lfloor\frac{n}{kd}\rfloor\lfloor\frac{m}{kd}\rfloor$
$=\sum_{T=1}^{n}\lfloor \frac{n}{T}\rfloor\lfloor \frac{m}{T}\rfloor\sum_{d|T}\mu(\frac{T}{d})d^{k}$
再设:$g(T)=\sum_{d|T}\mu(\frac{T}{d})d^{k}$
当T是质数时
$g(T)=T^{k}-1$
当i与p互质时
$g(i*p)=g(i)*g(p)$
当i与p不互质时
$g(i*p)=g(i)*p^{k}$
然后分块+线筛即可
标签:分享 desc sample style hellip 数学 line class sam
原文地址:http://www.cnblogs.com/Troywar/p/7353958.html