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
|
Abhinandan Agarwal:
2015-03-06 08:47:10
Finally in 0.01 time :-) |
|
Shubham Mohanka:
2015-03-04 15:10:22
@ron tle (time limit exceeded) is an error in case when ur program is not fast enough to complete in the given time limit.try using a faster algorithms.if u r a beginner,i will suggest u to google faster primality testing algos.hope that answers ur query.
|
|
ron:
2015-03-04 07:49:08
my program does what the problem is asking for but when I submit it shows TLE. can someone tell me why TLE? |
|
fordex:
2015-03-02 16:51:58
whats the best algorithm to generate primes between any two numbers? Last edit: 2015-03-02 16:52:41 |
|
Nootan R:
2015-02-28 15:03:48
SHOWING WRONG ANSWER
|
|
Shashank kumar:
2015-02-21 06:43:42
no need of seives ...just read an article on wikipedia...about primality test http://en.wikipedia.org/wiki/Primality_test |
|
Biswajit Sahu:
2015-02-19 09:16:56
I'm using Python 2.7.
|
|
SANKET MAKHIJA:
2015-02-18 10:54:46
sometimes basic worth it,,, no use of seive.. |
|
Siddhant Mishra:
2015-02-15 15:28:20
i am getting a runtime error
|
|
Sarvesh Kesharwani:
2015-02-14 15:30:51
use sieve to solve this question naive algo can also solve because of cube |
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 |