Submit | All submissions | Best solutions | Back to list |
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.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 |
hide comments
|
||||||||||||||
2013-11-16 21:02:34 LeppyR64
To those of you getting TLE. Think about what the hardest possible test case is. |
||||||||||||||
2013-11-05 20:45:11 Ryaan Dias
I am getting time limit exceeded but the code run very fast in ideone => http://ideone.com/4obog0 |
||||||||||||||
2013-11-02 18:37:41 Ashwini
my program runs successfully in ideone in 5 secs here judge is giving me tle:( <snip> Last edit: 2022-06-19 12:31:33 |
||||||||||||||
2013-11-01 11:50:08 Navaneeth R
do we have to give a condition for the boundary conditions in our code ? (i.e for the number's range) Last edit: 2013-11-01 11:50:28 |
||||||||||||||
2013-10-25 14:10:13 amit
my code runs properly on ideone,but online judge shows run time exceeded.Please help...<snip> Last edit: 2022-06-19 12:31:18 |
||||||||||||||
2013-10-24 22:38:33 Mohammed Hafez
@Shashikant Kumar : 1. your "return 0;" is in the loop 2. try defining m, n as "long long int" not "long" only as some compilers treat "long just as "int". Hope I helped :) |
||||||||||||||
2013-10-24 01:26:41 code_new
Always time limit exceeded |
||||||||||||||
2013-10-17 16:25:56 hector
What should be the output in case m = n (and assume m is not prime)? Should be it only black line or nothing at all? |
||||||||||||||
2013-09-18 22:30:11 Yuri Wergrzn
Runs in 0.12 sec but gives Wrong answer. I run as many test cases all over the range of values indicated and it works perfectly. Are trailing \n ignored (on end of output)? |
||||||||||||||
2013-09-02 09:03:09 Shashikant Kumar
Below is link for the code which is working in local system for a lot of test cases. But Judge is giving "Wrong Answer". <snip> Can anyone Please tell which testcase might not getting passed? Last edit: 2022-06-19 12:31:23 |