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-02-18 10:54:46 SANKET MAKHIJA
sometimes basic worth it,,, no use of seive.. |
||||||||||||||
2015-02-15 15:28:20 Siddhant Mishra
i am getting a runtime error http://ideone.com/****** can someone help (Francky)=> Please use forum for help, as pointed by the notes below. Last edit: 2015-02-15 16:26:25 |
||||||||||||||
2015-02-14 15:30:51 Sarvesh Kesharwani
use sieve to solve this question naive algo can also solve because of cube |
||||||||||||||
2015-02-14 13:34:09 Sanjay Gupta
My problem running time is .1 as per IDEone but still Spoj showing time limit exceed so Please suggest me How can i submit solution. re(vamsi): try to run your code against higher values of m, n. use forum.(post your code there incase you have any further queries) Last edit: 2015-02-19 12:34:45 |
||||||||||||||
2015-02-12 22:12:40 Archit Kapoor
Sooo after 17 attempts, I finally made it.. AC in the 18th attempt...!! Phew.. |
||||||||||||||
2015-02-11 19:18:01 Madhav
very good question!! |
||||||||||||||
2015-02-10 17:23:21 beginner
what is the output of : 1 1 1 (Francky) => Just output nothing for such cases. You can output an empty line if you want, as judge ignores extra whitespaces (spaces, new lines, tabs). Last edit: 2015-02-10 18:11:13 |
||||||||||||||
2015-02-06 15:45:44 Felipe
Don't get it.. I'm using Fermat Primality test, joined with a simple division of small prime numbers. Still, I have a TLE!! What can I do? re(vamsi): you can't pass TL by doing primality tests for all the numbers, try prime seives Last edit: 2015-02-06 19:53:52 |
||||||||||||||
2015-01-22 18:37:00 Abhimanyu Srivastava
i'm getting TLE using Sieve of erasthonesis algo |
||||||||||||||
2015-01-22 02:23:59 Arpan Das
@Binayaka: Can you please tell me what your issue was? |