https://hack.codingblocks.com/contests/c/126/821
I’m getting run-error for one test case.
My logic- if N>20, Find no of primes between 21 and N and print(N-(primes)-1) else if N<=20 print(N-1).
I have stored primes from 1 to 10^8 in arr using the prime sieve. But in constraints, its mentioned that the range of N is 10^18. How to find primes beyond that? Do I have to use Segmented Sieve?
Or, is there a better approach.