Prime Sieve problem

question )
https://hack.codingblocks.com/app/practice/3/1039/problem

my answer ) https://ide.codingblocks.com/s/246942

hello @N4i9kita
a) image
use long long in place of int to avoid overlfow

b) image
store cumullative sum before this loop and use that sum to answer each query in o(1).

refer this video tutorial by prateek bhaiya-> https://www.youtube.com/watch?v=8sniiDbfPK4

1 Like