PRIME1 - Prime Generator
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 5Warning: large Input/Output data, be careful with certain languages (though most should be OK if the algorithm is well designed)
Information
After cluster change, please consider PRINT as a more challenging problem.hide comments
Shrinidhi Sondur:
2013-03-29 07:04:53
The simplest way to go about this is the Sieve of Eratosthenes |
|
zbetmen:
2013-03-28 23:09:00
I have implemented segmented sieve of Eratosthenes and I'm getting wrong answer. I've covered even bad input and can't catch what's wrong. Can anybody suggest few good tests? |
|
ning zhu:
2013-03-24 11:23:29
why it is showing TEL
|
|
Sushant Mahajan:
2013-03-24 08:11:54
@Prabodh, time limit will exceed. This is not the way to handle this problem. Look into Sieve of Eratosthenes algo. http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes |
|
Harkrishn Patro:
2013-03-23 17:30:32
please help me someone mine time limit is getting exceeded |
|
Anudeep Samaiya:
2013-03-22 22:13:17
I have submitted the successful solution of this problem but no points are awarded...what should I do ? |
|
sunidhi:
2013-03-19 17:09:43
why it is showing runtime error |
|
Alex:
2013-03-15 19:26:09
Is it possible to fix the setup? Compiler of "stone age" doesn't understand int64_t and doesn't handle "long long" properly as well....
|
|
skard:
2013-03-13 22:12:29
maximum limit is 10^9. |
|
Santosh:
2013-03-13 22:12:29
What the hell? I guess the maximum limit of m,n is 10^10 instead of 10^9. My codes work only if I assume the maximum limit to be 10^10 !! |
Added by: | Adam Dzedzej |
Date: | 2004-05-01 |
Time limit: | 6s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: NODEJS PERL6 |