PRINT - Prime Intervals

no tags 

In this problem you have to print all primes from given interval.

Input

t - the number of test cases, then t lines follows. [t <= 150]
On each line are written two integers L and U separated by a blank. L - lower bound of interval, U - upper bound of interval. [2 <= L < U <= 2147483647] [U-L <= 1000000].

Output

For each test case output must contain all primes from interval [L; U] in increasing order.

Example

Input:

2
2 10
3 7

Output:

2
3
5
7
3
5
7

hide comments
deepamgupta: 2020-01-15 18:28:16

I'm getting TLE after applying Segemented Sieve but getting correct answer on my PC, what should I do to optimise?

Last edit: 2020-01-15 18:29:15
hetp111: 2019-09-29 07:37:25

(l/p)*p to find multiple of p in l to r.

a4w_1il: 2019-09-15 16:01:47

my code is faster than most of codes in the internet and yet tle !!

a4w_1il: 2019-08-29 21:58:11

never mind

Last edit: 2019-09-02 22:02:38
bogdanvlad: 2019-07-09 13:30:33

AC in one go!!!
Solved it with segmeted sieve.
Used ll in loops and printf, scanf.

iam_ram: 2019-06-17 16:08:39

My Code has no issues (Even I tried on Ideone and it is working fine). But on Submission, it's giving a Run time Error(NZEC).
Why is this happening ?

tien0903: 2019-06-14 10:44:09

bool f[10^6] :V but int not work :V

kartikay101: 2019-01-26 06:29:30

2 tle 1 wa finally AC

noobie_tr: 2018-10-16 04:50:51

they input nothing and time limit

eagleshadow: 2018-10-02 20:33:31

nothing , just same code as used in PRIME1
only change is, used printf scanf and my solution got accepted when i defined the segmented Sieve prime number array globally, with size 1000001
and do the same thing

Last edit: 2018-10-03 16:24:58

Added by:Roman Sol
Date:2005-03-28
Time limit:1.223s
Source limit:15000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ERL JS-RHINO NODEJS PERL6 VB.NET
Resource:ZCon