# 浅谈整除分块

### 模型：

$$\sum_{i=1}^{n}\left\lfloor\frac{n}{i}\right\rfloor$$

$$i$$ 1 2 3 4 5 6 7 8
$$8/i$$ 8 4 2 2 1 1 1 1

### 变形0：

$$\left\{\begin{array}{l}k1=\left\lfloor\frac{n}{l}\right\rfloor,k2= \left\lfloor\frac{m}{l}\right\rfloor\\ r=\max (i), i \times k1 \leq n,i\times k2 \le m\end{array}\right.$$
$$r = min(\lfloor\frac{n}{k1}\rfloor,\lfloor\frac{m}{k2}\rfloor)$$

### 变形1：

$$i' = a\times i + b$$，先求出 $$\left\lfloor\frac{n}{i'}\right\rfloor$$ 的整除分块

$$\left\{\begin{array}{l}i'=a\times i +b \\ r'=\max (i')\end{array}\right.$$$$\begin{cases}a\times i=i'-b\\ i=\dfrac{i'-b}{a}\end{cases}$$$$r=max(i)= max(\left\lfloor\frac{i'-b}{a}\right\rfloor) = \lfloor\frac{r'-b}{a} \rfloor$$
$r =\left \lfloor \dfrac{\left \lfloor \dfrac{n}{\lfloor \dfrac{n}{a\times l+b}\rfloor }\right \rfloor -b}{a}\right \rfloor$

### 变形2：

$$i' = i^2$$，先求出 $$\left\lfloor\frac{n}{i'}\right\rfloor$$ 的整除分块

$$\left\{\begin{array}{l}i=\sqrt{i'} \\ r'=\max (i')\end{array}\right.$$$$r = max(i) = max(\lfloor\sqrt{i'} \rfloor) = \lfloor r' \rfloor = \lfloor\sqrt{\left\lfloor\frac{n}{\left\lfloor\frac{n}{l^2}\right\rfloor}\right\rfloor}\rfloor$$

### 变形3：

$$n$$ 整除 $$i$$ 时，$$\left\lceil\frac{n}{i}\right\rceil = \left\lfloor\frac{n}{i}\right\rfloor$$
$$n$$ 不整除 $$i$$ 时，$$\left\lceil\frac{n}{i}\right\rceil = \left\lfloor\frac{n}{i}\right\rfloor + 1$$

$$\because i \times k \le n+i-1 \Rightarrow i\times(k-1) \le n-1$$
$$\therefore r=\left\lfloor\frac{n-1}{k-1}\right\rfloor=\left[\frac{n-1}{\left\lfloor\frac{n+l-1}{l} \mid-1\right.}\right\rfloor$$

posted @ 2021-05-10 15:48  GsjzTle  阅读(168)  评论(9编辑  收藏  举报