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!


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.


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.


1 10
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
Time limit:6s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel Pentium G860 3GHz)
Languages:All except: NODEJS PERL 6

hide comments
2014-10-24 17:59:42 Nagaraj TV
is there any problem friends,,please tell me.http://ideone.com/BC7sOu
2014-10-23 19:14:22 surbhit21
Finally!! ;)
2014-10-23 15:49:42 Md ABDUL MOMIN
anyone please help me what's wrong in this solution
2014-10-23 11:38:13 nico limbara
some1 please help.
2014-10-23 10:45:06 Diksha Jaiswal
took time to implement sieve bt finally AC :)
2014-10-22 11:10:10 Daniel Cárdenas
Solved it on python. Finally.
2014-10-21 22:38:21 Shubham Bharti
first thing i want to remove a misconception that there is no need to make array of test cases as u have done in ur ideone link.U can simply evaluate the answer of each test case and print that simultaneously (means input-output simultaneously for each n every test case)

Last edit: 2014-10-21 22:39:24
2014-10-14 16:45:04 inaya
the code is showing (SIGSEGV).
I am not able to understand whats wrong.
2014-10-12 18:30:50 Mitch Schwartz
@Paradigm Shift: The standard judge on SPOJ ignores extra whitespace. Only in rare cases is a different judge used, and most of the time there is a note about it in the problem statement or a comment about it.
2014-10-12 17:35:29 Paradigm Shift
WHAT TO PRINT WHEN THERE IS NO PRIME..A SPACE LINE CORRESponding to it or just ignore that test case ?
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.