Sphere Online Judge

SPOJ Problem Set (classical)

2. Prime Generator

Problem code: PRIME1


Peter wants to generate some prime numbers for his cryptosystem. Help him! Your task is to generate all prime numbers between two given numbers!

Input

The input begins with the number t of test cases in a single line (t<=10). In each of the next t lines there are two numbers m and n (1 <= m <= n <= 1000000000, n-m<=100000) separated by a space.

Output

For every test case print all prime numbers p such that m <= p <= n, one number per line, test cases separated by an empty line.

Example

Input:
2
1 10
3 5

Output:
2
3
5
7

3
5
Warning: large Input/Output data, be careful with certain languages (though most should be OK if the algorithm is well designed)
Added by:Adam Dzedzej
Date:2004-05-01
Time limit:6s
Source limit:50000B
Memory limit:256MB
Cluster: Pyramid (Intel Pentium III 733 MHz)
Languages:All except: NODEJS PERL 6

hide comments
2014-09-02 05:49:14 Ashutosh Verma
DS ka lecture hai yaarrrrrr :( @Devashish


Last edit: 2014-09-02 05:49:37
2014-09-02 05:48:32 Ashutosh Verma
fuck off
2014-08-31 21:28:39 RUBAL GUPTA
Please help me out : getting run time error : SIGXFSZ , not having any idea.
2014-08-30 17:00:15 shivam goyal
.

Last edit: 2014-08-31 11:45:49
2014-08-27 22:55:25 ANURAG PANDEY
TIME LIMIT EXCEEDED :(
PLEASE HELP ME OUT!!
http://ideone.com/c55cdL
2014-08-25 16:07:24 durairajaa
please some one explain me what is the input in problems (i.e file/standard input)

please explain me the procedure for submitting the problems

Last edit: 2014-08-25 16:10:42
2014-08-22 12:19:08 NAMISH SHAH GUPTA
@Devashish Rawat never use strlength() in SPOJ
2014-08-20 20:01:27 Priscilla Imandi
Im getting a time limit exceeded problem. what should i do. plz help
2014-08-16 20:58:59 Sachin Gautam
solved without using segmented sieve :P
2014-08-16 15:47:21 Swapnil Borse
can anyone kindly tell me where will I find an awesome explanation of the segmented sieve of erathosthenes???
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.