PRINT - Prime Intervals

no tags 

In this problem you have to print all primes from given interval.

Input

t - the number of test cases, then t lines follows. [t <= 150]
On each line are written two integers L and U separated by a blank. L - lower bound of interval, U - upper bound of interval. [2 <= L < U <= 2147483647] [U-L <= 1000000].

Output

For each test case output must contain all primes from interval [L; U] in increasing order.

Example

Input:

2
2 10
3 7

Output:

2
3
5
7
3
5
7

hide comments
eagleshadow: 2018-10-02 20:33:31

nothing , just same code as used in PRIME1
only change is, used printf scanf and my solution got accepted when i defined the segmented Sieve prime number array globally, with size 1000001
and do the same thing

Last edit: 2018-10-03 16:24:58
codaras: 2018-08-13 15:18:12

This problem TL is not proper . even Miller rabin will TIE

spojabhi: 2018-05-20 09:26:45

use printf ,scanf and long long int in loop variable
int costed me 1 tle .

neverhopeless: 2018-04-27 13:49:56

@Roman Sol, @all
Is this 1.223 seconds the time to run 150 test cases or 1 test case ?
I am able to run worst case 6 times in the given time period using python 3, but still getting TLE. :(
Any help!

Last edit: 2018-05-15 14:41:08
ashish2050: 2018-04-07 07:52:23

TLE but don't know why coz its running perfectly in my ide

shivr1: 2018-03-19 20:51:15

PLEASE KEEP IN MIND to use scanf,printf and not fast i/o

sharingancoder: 2018-03-11 12:10:41

it is giving tle even with sieve of eratosthenes.
Any idea which approach should be used ??

code0monkey1: 2018-02-17 16:45:56

really helpful video tutorial ( the tutorial is partially in Hindi , so it would be difficult for non-Hindi speaking people to understand what the presenter is saying ) based on this specific question : https://www.youtube.com/watch?v=fByR5N-TseY&t=650s

sanyam19: 2018-01-08 15:30:45

took 2 hrs... but finally done... :))
prime generator ka thda sa changed roop....
use sieve method....
=>[U-L <= 1000000]<= constraint (dont forget this)

captaindavinci: 2017-10-16 18:46:12

Why does Rabin Miller test with memoization not work for this problem? Isn't Rabin Miller a logarithmic computation with fast modular exponentiation.


Added by:Roman Sol
Date:2005-03-28
Time limit:1.223s
Source limit:15000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ERL JS-RHINO NODEJS PERL6 VB.NET
Resource:ZCon