标题
增加 1 行删除 1 行
1题解:SP22412 DIVFACT3 - Divisors of factorial (hard)1Solution: SP22412 DIVFACT3 - Divisors of factorial (hard)
正文
增加 2 行删除 2 行
48 行未改动4950515253545556575859606198 行未改动48 行未改动Second part:$$\prod\limits_{p_i \in (B,N]} \left( \left\lfloor \frac{N}{p_i} \right\rfloor + 1 \right).$$Consider floor division trick. For a block $[l,r]$, its contribution is:$$\left( \left\lfloor \frac{N}{l} \right\rfloor + 1 \right) ^ {\left( \pi(r) - \pi(l-1) \right)}.$$Precomputing all $\pi(i)$ ($i \le N$) using the linear sieve, which has complexity $\mathcal{O}(N)$.The complexity of the floor division trick is $\mathcal{O}(\sqrt{N} \log N)$.Thus the second part is calculated in $\mathcal{O}(\sqrt{N} \log N)$.98 行未改动48 行未改动4950515253545556575859606198 行未改动48 行未改动Second part:$$\prod\limits_{p_i \in (B,N]} \left( \left\lfloor \frac{N}{p_i} \right\rfloor + 1 \right).$$Consider the floor division trick. For a block $[l,r]$, its contribution is:$$\left( \left\lfloor \frac{N}{l} \right\rfloor + 1 \right) ^ {\left( \pi(r) - \pi(l-1) \right)}.$$Precompute all $\pi(i)$ ($i \le N$) using the linear sieve, which has complexity of $\mathcal{O}(N)$.The complexity of the floor division trick is $\mathcal{O}(\sqrt{N} \log N)$.Thus the second part is calculated in $\mathcal{O}(\sqrt{N} \log N)$.98 行未改动