数论分块学习
用途
快速计算含有\(\lfloor{\frac{n}{i}}\rfloor\)的和式(\(i\)为变量)
引理
引理1
\[\forall a,b,c\in \mathbb{N_+},\quad \Big\lfloor \frac{a}{bc}\Big\rfloor=\bigg\lfloor \frac{\lfloor \frac{a}{b}\rfloor}{c}\bigg\rfloor \]证明1
\[\text{let}\quad \{x\}=x-\lfloor x\rfloor\quad\therefore \{x\}\in [0,1)\\ \Big\lfloor \frac{a}{bc}\Big\rfloor=\Bigg\lfloor \bigg(\Big\lfloor\frac{a}{b}\Big\rfloor+\Big\{\frac{a}{b}\Big\}\bigg)\frac{1}{c}\Bigg\rfloor\ge\bigg\lfloor \frac{\lfloor \frac{a}{b}\rfloor}{c}\bigg\rfloor\\ \because \Big\{\frac{a}{b}\Big\}<1\le c-\bigg(\Big\lfloor\frac{a}{b}\Big\rfloor\mod c\bigg)\\ \therefore \Big\lfloor \frac{a}{bc}\Big\rfloor=\Bigg\lfloor \bigg(\Big\lfloor\frac{a}{b}\Big\rfloor+\Big\{\frac{a}{b}\Big\}\bigg)\frac{1}{c}\Bigg\rfloor <\Bigg\lfloor \bigg(\Big\lfloor\frac{a}{b}\Big\rfloor+c-\Big(\Big\lfloor\frac{a}{b}\Big\rfloor\mod c\Big)\bigg)\frac{1}{c}\Bigg\rfloor=\bigg\lfloor \frac{\lfloor \frac{a}{b}\rfloor}{c}\bigg\rfloor+1\\ \therefore \bigg\lfloor \frac{\lfloor \frac{a}{b}\rfloor}{c}\bigg\rfloor\le \Big\lfloor \frac{a}{bc}\Big\rfloor <\bigg\lfloor \frac{\lfloor \frac{a}{b}\rfloor}{c}\bigg\rfloor+1\\ \therefore \Big\lfloor \frac{a}{bc}\Big\rfloor=\bigg\lfloor \frac{\lfloor \frac{a}{b}\rfloor}{c}\bigg\rfloor \]注:该引理并不会被用到,这里只是把oiwiki上的证明丰富一下
引理2
\[\forall d\le n\in \mathbb{N_+},\quad|\{\lfloor \frac{n}{d}\rfloor\}|\le 2\lfloor\sqrt{n}\rfloor \]证明2
\[\text{when}\quad d\le \lfloor\sqrt{n}\rfloor ,\quad|\{\lfloor \frac{n}{d}\rfloor\}|\le|\{d\}|=\lfloor\sqrt{n}\rfloor\\ \text{when}\quad d>\lfloor\sqrt{n}\rfloor,\because \lfloor \frac{n}{d}\rfloor\le\sqrt{n}\therefore |\{\lfloor \frac{n}{d}\rfloor\}|\le|\{i\le\lfloor\sqrt{n}\rfloor\in\mathbb{N_+} \}|=\lfloor\sqrt{n}\rfloor \]注:该引理只用于证明复杂度