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
|
||||||||||||||
2014-05-28 07:07:31 David Winiecki
The first line is a single number, indicating the number of lines of input that follow. |
||||||||||||||
2014-05-27 22:54:16 amala
How does one know that the user has finished entering input values? Say he gives just 1 line of input--> 1 3. (Nothing afterwards)How is this handled? |
||||||||||||||
2014-05-24 09:44:07 Wasim Thabraze
@sourabh sharma ..Use segmented sieve of eratosthenes :) |
||||||||||||||
2014-05-24 08:32:08 Akshay Vilekar
Can anyone provide hint which data structure I should use ? |
||||||||||||||
2014-05-24 06:09:39 PRITHA GANGULY
time limit exceeded! :( how do I solve this? |
||||||||||||||
2014-05-22 15:47:07 Sourabh Sharma
can anyone tell what are the techniques of optimization to avoid time limit problem? any link ..?help |
||||||||||||||
2014-05-21 21:23:54 Kaushal Manna
how to reduce the time limit?? anyone...anyidea |
||||||||||||||
2014-05-21 13:41:52 Michael Moerschell
If there is no output for a testcase (e.g.: 32 33), has the program to print an empty line? --ans(Francky)--> Judge ignore extra-whitespace, so you can can add an empty line, or not, it doesn't matter. Good luck. Last edit: 2014-05-21 13:58:57 |
||||||||||||||
2014-05-21 13:40:07 Michael Moerschell
To fix TLE error: http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes |
||||||||||||||
2014-05-21 13:11:01 Pratyush Sharan
How to remove the time limit exceeded error in C? Can someone post some special test cases here? My code is running perfectly fine . |