1 / 11
Oct 2014

t=input()
c=1
if t<=10:
    while c<=t:
         m=input()
         n=input()
         if n-m<=100000 and m>=1 and n<=1000000000:
             while m<=n:
                 a=2
                 while a<m:
                    if m%a==0:break
                    else:
                        a+=1
                 if a==m:
                     print m
                 m+=1 
         c+=1

I'm not a python user, but doesn't input() read a whole line?

2
1 10
3 5

I suspect that m=input() would fail on "1 10".

cant it read like this
[color=#FF40BF]2[/color]
1
10
[color=#40BF00]2
3
5
7[/color]
3
5
[color=#80BF00]3
5[/color]

The input is structured as it is listed in the problem statement.

Again, not a python user but I think it's like this:

n,m = input().split(' ')

now this code is returning time limit exceed

t=input()
c=1
if t<=10:
    while c<=t:
         n,m =raw_input().split()
         x=int(n)
         y=int(m)
         while x<=y:
            a=2
            while a<x:
                if x%a==0:break
                else:
                    a+=1
            if a==x:
                print x
            x+=1 
         c+=1

now ,what i do?
help me @leppy

You should learn Eratosthenes Sieve methods.
This code is by far a too naive one.

You should try some cases by your own to check the speed of your program.
eg :

5
100 200
1000 1100
10000 10100
100000 100100
1000000 1000100

and after that

5
100000 200000
1000000 1100000
10000000 10100000
100000000 100100000
900000000 1000000000

Good luck

Suggested Topics

Want to read more? Browse other topics in Python or view latest topics.