版本比较
Solution: SP22412 DIVFACT3 - Divisors of factorial (hard)
标题
增加 1 行删除 1 行
11题解:SP22412 DIVFACT3 - Divisors of factorial (hard)Solution: SP22412 DIVFACT3 - Divisors of factorial (hard)正文
增加 2 行删除 2 行
48 行未改动49505152535354555657575859606198 行未改动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: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)}.$$
Precomputing all $\pi(i)$ ($i \le N$) using the linear sieve, which has complexity $\mathcal{O}(N)$.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 行未改动