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
imkiran:
2015-12-16 09:18:02
what could be the reason for runtime error ?
|
|
kartik_dtu:
2015-12-15 19:43:25
Lookup segmented sieve on geeksforgeeks
|
|
coderthakur:
2015-12-10 22:23:28
i am getting segmentation error.Can anyone help me? |
|
algo_aris:
2015-12-08 21:55:07
Very interesting task for double sieve of Eratosthenes, thanks.
|
|
yogi9046:
2015-12-05 14:34:23
done it , but it take 3.44 sec...can someone suggest me a better solution.. i tried with sieve algo |
|
sumbayak_ae:
2015-12-05 12:52:18
how can I go faster than 0.24 ?
|
|
igotitproducts:
2015-12-04 21:05:59
I am getting wrong answer, although when i run on any other IDE i produce correct results.??? |
|
nyreios:
2015-12-02 18:27:13
well bruteforce didnt work i guess ;D |
|
Dushyant Singh:
2015-12-02 16:11:16
@ysn - It's far simple than Topcoder. You simply have to make a program which takes 't' that is number of test cases as input then take input for each test case which will be of form 'm' and 'n' then you have to print prime numbers from m to n (inclusive). Do not forget to print each prime in newline. I am still struggling how to work in Topcoder arena. :-| |
|
ysn:
2015-12-02 10:48:25
i migrated from Topcoder and project euler. on Topcoder, you just write your code and declare the variables as indicated. but here i think its diffrent; the input is in lines not simply an array, int,String... as Topcoder. so how am i supposed to make my code to accept the inputs? by a scan method? |
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 |