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

Автор Hamim99, история, 4 года назад, По-английски

Can anyone give me hints for this proplem? https://www.spoj.com/problems/CNTPRIME/

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

»
4 года назад, # |
  Проголосовать: нравится +2 Проголосовать: не нравится

Segtree + lazy works

  • Run a sieve to find primes less than $$$10^{6}$$$
  • Read input and only store if each number is a prime or not
  • Build a sum segtree
  • For query of type 0 just do a lazy update on the segment x y ie. change all the values to isPrime(v)
  • For query of type 1, return the sum.

Sorry I don't know how to link SPOJ codes so I posted the code here

Code