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
5
Warning: 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
Md. Baker Hossen: 2014-01-17 15:15:32

----Adam Dzedzej
In Ideone My code has successfully runned.
But When I submit spoj It shows me "Time Limit Exceeded".
What's Problem Please Explain me.
<snip>

Last edit: 2022-06-19 12:35:00
appy: 2014-01-16 09:31:15

tle error...how to do such programs....can sum1 explain any algo associated with dis problem

Cristian Maruan Bosin: 2014-01-09 20:45:19

I have no idea why my code is taking so much time to run.. I've tried lots of times different submissions and all of those has the same problem.. Is this just happening to me ?? :/ (problem: time limit exceeded)

My code: <snip>

Last edit: 2022-06-19 12:33:23
Douglas De Rizzo Meneghetti: 2014-01-09 17:16:15

Hey guys, I solved it, but when I submit, I receive a SIGSEGV. Can someone spot the mistake?

<snip>

Last edit: 2022-06-19 12:34:06
Micha³ Klawikowski: 2014-01-07 18:56:43

@Babita u're scanning only 10 first digits, no matter how many cases is bound to be done.
Besides writing anything BUT the answer mentioned in the description will be tolerated as invalid.

Babita Naagar: 2014-01-05 05:35:01

I have written the code, it runs perfectly on ideone too, but here it is showing a run time error. I have read it several times but haven't been able to spot any error. Please help.
Here is the code : <snip>

Last edit: 2022-06-19 12:34:01
Rishiraj: 2014-01-02 19:56:15

are "Command line arguments" valid ???

Sahebjot Singh: 2014-01-02 19:05:14

I am getting wrong answer as the reply,
But I am getting the right answer for the test cases.
I added a new line between inputs aswell.
I am not taking the inputs with a space in between, is that necessary?
<snip>

Last edit: 2022-06-19 12:33:55
Sayed Jaffar: 2013-12-23 16:38:47

I have one question..
"t" from where I can get it ??
can I put it equal 10 or what ??

Rohan Jitendra Pota: 2013-12-22 08:45:34

[code removed]
its showing time limit exceeded.what to do ?plplzzzzzhelp!!

(Mitch) ---
"1. Don't post any source code here."

You may try the forum for help with such things.

Edit: I see that you already did, but you either didn't read TripleM's post "Read this before posting!" or you didn't take it to heart. So you might want to go and do that. But anyway your problem is simple enough, I'll reply to that thread you started.
---

Last edit: 2013-12-22 09:32:30

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