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:1536MB
Cluster: Cube (Intel Pentium G860 3GHz)
Languages:All except: NODEJS PERL 6

hide comments
2014-10-14 16:45:04 inaya
http://ideone.com/OHBTus
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 ?
2014-10-10 21:09:22 Shubajit Saha
@NOOGER check m<=n condition .
2014-10-08 15:04:05 SaurabhSakpal
Finally!!! :D
2014-10-05 23:07:43 The one who never told the truth.....
Finally!!!! :D
2014-10-03 03:13:45 Nooger
I've implemented segmented seive of erasthoneses. Output is correct but the judge is throwing a TLE.
What to do? Please tell me what's wrong with my code.
http://ideone.com/ZwzHoM

Last edit: 2014-10-03 05:08:20
2014-10-02 13:27:32 mukul arora
@sanchi the normal method to find the prime won't work here
it use other algo.....!!!
me too stuck in same....google it u will find algo
2014-09-29 19:08:09 Raja Das
"http://ideone.com/e.js/B325s9"
its working on ideone but its not working in spoj.its showing time limit exceeds..Whats the problem..help me..
2014-09-25 13:13:32 Yash Bansal
This is my code. Why i am getting it as wrong answer even it is working fine on my pc compiler?
Please help.
[code removed by cyclops -- see notes at bottom, "1. Don't post any source code here." You may be interested in the forum; be sure to read TripleM's "Read this before posting!" and Leppy's "PLEASE USE CODE TAGS" before posting.]

Last edit: 2014-09-25 16:52:03
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.