莫比乌斯反演
随便整理下,其实我也不是很懂
整除分块
\(\lfloor \frac{n}{i} \rfloor \leq \frac{n}{i} \implies i \leq \lfloor \frac{n}{\lfloor \frac{n}{i} \rfloor} \rfloor\)
即\(\lfloor \frac{n}{i} \rfloor = k\),\(i\)能取到的最大值为\(\lfloor \frac{n}{\lfloor \frac{n}{i} \rfloor} \rfloor\)
狄利克雷卷积
\((f*g)(n)=\sum_\limits{d|n}f(d)g(\frac{n}{d})\)
满足交换律、结合律
常用积性函数
欧拉函数:\(\varphi(n)=\large\sum_{i=1}^{n}[gcd(i,n)=1]\)
莫比乌斯函数:\(\mu(n) = \begin{cases} 1 & n=1\\ 0 &n=p_1^{a_1}p_2^{a_2}...p_k^{a_n} (\exists a_i>1,即n含有平方因子)\\(-1)^k & n=p_1p_2...p_k \end{cases}\)
单位函数:\(\epsilon(n) = [n = 1]\)
恒等函数:\(id_(n) = n\)
常数函数:\(I(n) = 1\)
除数函数:\(\sigma(n)或d(n) = \sum \limits_{d|n}1(即因数个数)\)
线性筛莫比乌斯函数
void get_mu(int n) {
mu[1] = 1;
for(int i = 2; i <= n; i++) {
if(!vis[i]) {
prime[++cnt] = i;
mu[i] = -1;
}
for(int j = 1; j <= cnt && i*prime[j] <= n; j++) {
vis[i*prime[j]] = true;
if(i%prime[j]==0) break;
else mu[i*prime[j]] = -mu[i];
}
}
}
性质
\(\mu*I=\epsilon\)
\(\varphi*I=id\)
\(id*\mu=\varphi\)
\(I*I=d\)
\(I*id=\sigma\)
莫比乌斯反演
设\(F(n)=\sum_{d|n}f(d)\),则
\(\begin{array}{l} f(n) = \sum\limits_{d|n} {\mu(d)F(\lfloor\frac{n}{d}\rfloor)} \\ f(n) = \sum\limits_{n|d} {\mu(\lfloor\frac{d}{n}\rfloor)F(d)} \end{array}\)
常用结论
\(\because \sum\limits_{d∣n}\mu(d)=[n=1]\)
\(\therefore [gcd(i,j)=1]=\sum\limits_{d∣gcd(i,j)}μ(d)\)
\(\sum\limits_{d|n}\frac{\mu(d)}{d}=\frac{\varphi(n)}{n}\)
\(\because \varphi(n) = \sum_{d|n}\mu(d)\frac{n}{d}\)
由莫比乌斯反演得
\(\therefore n = \sum_{d|n}\varphi(d)\)