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
nbisht30:
2015-06-09 03:57:56
The size of sieve array is becoming very large in worst case. What to do? |
|
ninja_white:
2015-06-08 05:41:22
Use the primality test, with that finally solved the problem of time, that is the solution and also optimize your code so that no repetition ranges and evaluated .. Greetings
|
|
lvn_anand:
2015-06-07 13:38:31
I tried two problems in Java. Both show runtime error NZEC as many times as I try.
|
|
Sagar Karira:
2015-06-07 13:22:36
To avoid TLE calculate all the primes one time only and print the one which are asked . |
|
revagupta:
2015-06-07 12:59:45
code working in ideone but showing time limit exceeded in spoj. please help |
|
ninja_white:
2015-06-06 16:51:11
"Time Limit Exceeded" in Java? What should I do? in Ideone runs and immediately gives perfect results
|
|
topcoder007:
2015-06-06 08:56:51
time limit exceeded in c running properly in ideone any alternative ? |
|
apratim_12b:
2015-06-06 08:56:48
NZEC error in python. I have added exceptions for EOFError and ValueError, and it is working as expected on my pc. Here it is showing NZEC. Can anyone tell me why?
|
|
achugh95:
2015-05-31 21:20:14
"Time Limit Exceeded" in C++? What should I do?
|
|
ismail_web:
2015-05-31 11:58:17
someone can help me plz : when I submit my answer .. they give to me : " runtime error (SIGSEGV) "
|
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 |