P2257 YY的GCD (莫比乌斯反演)

题意:求\[\sum_{i=1}^{n}\sum_{j=1}^{m}[gcd(i,j) = prim]\]
题解:那就开始化式子吧!!
\[f(d) = \sum_{i=1}^{n}\sum_{j=1}^{m}[gcd(i,j) = d]\]
\[F(x) = \sum_{d|x} f(d) = \left \lfloor \frac{n}{x} \right \rfloor \left \lfloor \frac{m}{x} \right \rfloor\]
\[f(d) = \sum_{d|x} \mu\left ( \frac{x}{d} \right )F(x) \]
\[ans= \sum_{p \in prim}f(p)=\sum_{p \in prim}\sum_{p|x} \mu\left ( \frac{x}{p} \right )\left \lfloor \frac{n}{x} \right \rfloor \left \lfloor \frac{m}{x} \right \rfloor \]

猜你喜欢

转载自www.cnblogs.com/lwqq3/p/10346545.html
今日推荐