Segmented sieve - MarisaOJ: Marisa Online Judge

Segmented sieve

Time limit: 1000 ms
Memory limit: 256 MB
Given an 2 integers $L, R$. Find all primes in range $[L, R]$. ### Input - The first line contains 2 integers $L, R$. ### Output - Print all primes in range $[L, R]$ in ascending order. ### Constraints - $1 \le L \le R \le 10^{12}$. - $1 \le R - L + 1 \le 10^6$. ### Example Input: ``` 20 30 ``` Output: ``` 23 29 ```