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
|
||||||||||||||
2015-06-09 03:57:56
The size of sieve array is becoming very large in worst case. What to do? |
||||||||||||||
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 P.S. People need to poye more with tips like I'm giving for example. And they had people who had resolved but did not share a clue. We must be more friendly. Regards |
||||||||||||||
2015-06-07 13:38:31
I tried two problems in Java. Both show runtime error NZEC as many times as I try. What am I obviously doing wrong? |
||||||||||||||
2015-06-07 13:22:36 Sagar Karira
To avoid TLE calculate all the primes one time only and print the one which are asked . |
||||||||||||||
2015-06-07 12:59:45
code working in ideone but showing time limit exceeded in spoj. please help |
||||||||||||||
2015-06-06 16:51:11
"Time Limit Exceeded" in Java? What should I do? in Ideone runs and immediately gives perfect results WHAT HAPPENED HERE? Last edit: 2015-06-06 17:06:21 |
||||||||||||||
2015-06-06 08:56:51
time limit exceeded in c running properly in ideone any alternative ? |
||||||||||||||
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? |
||||||||||||||
2015-05-31 21:20:14
"Time Limit Exceeded" in C++? What should I do? |
||||||||||||||
2015-05-31 11:58:17
someone can help me plz : when I submit my answer .. they give to me : " runtime error (SIGSEGV) " I use C++ and C but the same problem. I don't what I should do .. |