[BZOJ3994] [SDOI2015]约数个数和

首先有一个结论$d(i*j)=\sum \limits _{x\mid i} \sum \limits _{y\mid j}\left [ gcd(i,j)=1 \right ] $

结论有点难想,不过之后就比较简单了。

$\sum \limits _{i=1}^{N}\sum \limits _{j=1}^{M} \sum \limits _{x\mid i} \sum \limits _{y\mid j}\left [ gcd(x,y)=1 \right ]$

$\sum \limits _{i=1}^{N} \sum \limits _{j=1}^{M} \sum \limits _{x\mid i}\sum \limits _{y\mid j}\sum \limits _{g\mid gcd(i,j)}u(g)$

$\sum \limits _{x=1}^{N}\sum \limits _{{i}'=1}^\left \lfloor \frac{N}{x} \right \rfloor \sum \limits _{y=1}^{M}\sum \limits _{{j}'=1}^{\left \lfloor \frac{M}{y} \right \rfloor}\sum \limits _{g\mid gcd(x,y)}u(g)$

$\sum \limits _{x=1}^{N}\sum \limits _{y=1}^{M} \sum \limits _{g\mid gcd(x,y)}u(g) \left \lfloor \frac{N}{xg} \right \rfloor \left \lfloor \frac{M}{yg} \right \rfloor$

$\sum \limits _{g=1}^{min(N,M)} u(g)\sum \limits _{x=1}^{\left \lfloor \frac{N}{g} \right \rfloor}\sum \limits _{y=1}^{\left \lfloor \frac{M}{g} \right \rfloor}\left \lfloor \frac{N}{xg} \right \rfloor \left \lfloor \frac{M}{yg} \right \rfloor$

设$f(T)=\sum \limits _{T=1}^{N}\left \lfloor \frac{N}{T} \right \rfloor$

那么原式=$\sum \limits _{g=1}^{min(N,M)} u(g) f(\left \lfloor \frac{N}{g} \right \rfloor) f(\left \lfloor \frac{M}{g} \right \rfloor)$

整除分块预处理f函数就可以了。

波澜前,面不惊。
posted @ 2019-10-10 06:24  Al_Ca  阅读(77)  评论(0编辑  收藏  举报
ヾ(≧O≦)〃嗷~