莫比乌斯反演


积性函数$$\forall p,q \wedge gcd(p,q)=1 , f(pq)=f(p)*f(q)$$


\(\mu\)函数定义

$$

n=a_1{p_1}*a_2\cdots*a_k^{p_k}\
\mu(n)=\left{
\begin{array}{lr}
1,n = 1\
(-1)^k,a_i=1\
0,otherwise
\end{array}
\right.

\[ --------------------------------------------- ##**$\mu$函数性质** ###1.\]

\sum_{d|n}\mu(d)=[n=1]

\[([n=1]表示仅当n=1时返回值为1,其余为0) ###2.\]

\sum_{d|n}{\mu(d)\over{d}}={\varphi(n)\over{n}}

\[ --------------------------------------- ##**线性筛莫比乌斯函数** ```cpp void init() { memset(vis,0,sizeof vis); mu[1]=1; for (int i=2;i<=n;++i) { if (!vis[i]) { mu[i]=-1; prime[++tot]=i; } for (int j=1;j<=tot&&i*prime[j]<=n;++j) { vis[i*prime[j]]=1; if (i%prime[j]==0) { mu[i*prime[j]]=0; break; } else { mu[i*prime[j]]=-mu[i]; } } } } ``` ----------------------------------------- ##**莫比乌斯反演** ### 若$$F(n)=\sum_{d|n}f(d)\]

则有 $$f(n)=\sum_{d|n}\mu(d)*F({{n}\over{d}})$$

证明

$$\sum_{d|n}\mu(d)F(\frac{n}{d})=\sum_{d|n}\mu(d)\sum_{k|\frac{n}{d}}f(k)\

=\sum_{p|n}f(p)\sum_{k|\frac{n}{p}}\mu(k)\ \ \ \ (p=dk)\\
=\sum_{p|n\wedge p\neq n}f(p)\sum_{k|\frac{n}{p}}\mu(k)+f(n)\sum_{k|1}\mu(k)\\=0+f(n)
=f(n)

\[ ------------------- ###**另一种形式** ### 若$$F(n)=\sum_{n|d}f(d)\]

则有 $$f(n)=\sum_{n|d}\mu(\frac {d} {n})*F({d})$$

另一种形式证明

$$\sum_{n|d}\mu(\frac{d}{n})F(d)=\sum_{n|d}\mu(\frac{d}{n})\sum_{d|p}f(p)\

=\sum_{q=1}^{+\infty}\mu(q)\sum_{nq|p}f(p)\ \ \ \ \ (q=\frac{d}{n})\
=\sum_{n|p}f(p)\sum_{q|\frac{p}{n}}\mu(q) \ \ \ \ \ \ \ \ \ \ \ \ \
=\sum_{n|p \wedge n\neq p}f(p)\sum_{q|\frac{p}{n}}\mu(q)+f(n)\sum_{q|1}\mu(q)\
=0+f(n)=f(n)\

\[1 1 1 1 1 1 1 1 1 1 1 ###$$f(d)=\sum_{i=1}^{n} \sum_{j=1}^{m} [gcd(i,j)=d]\]

$$F(d)=\sum_{i=1}^{n} \sum_{j=1}^{m} [d|gcd(i,j)]=n/d*m/d$$

$$F(d)=\sum_{d|p} f(p)$$

$$f(n)=\sum_{n|d}\mu(\frac {d} {n})*F({d})$$

$$f(1)=\sum\mu(d)*F({d})$$

posted @ 2019-08-07 06:51  keep_solving  阅读(98)  评论(1编辑  收藏  举报