Блог пользователя tbquan08hanoi

Автор tbquan08hanoi, история, 21 месяц назад, По-английски

Hello codeforces!

I have a problem: counting primes in $$$[m, n)$$$ where $$$1 \lt =m \lt n \lt =2 \cdot 10^9$$$.

Because the range could be large, I can't use sieve because of the memory complexity or normal primality test in $$$O(sqrt(n))$$$

Thanks very much!

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
21 месяц назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Check again your problem, may be you can sieve on range?

»
21 месяц назад, скрыть # |
 
Проголосовать: нравится +14 Проголосовать: не нравится

We call P(i) = the number of primes <= i

The answer for the problem is P(N - 1) - P(M - 1)

since N <= 2 * 10^9, we can preprocess 2000 integers where the i-th one shows P(i * 10^6)

The leftover length is not bigger than 10^6 so you can sieve on that range, it should pass the time limit.

»
21 месяц назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится