forked from iamaunique/CODECHEF-PYTHON
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodechefsqr.py
33 lines (32 loc) · 1.72 KB
/
codechefsqr.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from math import sqrt
def x(n):
a=['0','1','4','9']
x=str(n)
for i in x:
if i not in a:
return False
return True
def y():
i=1
p=[]
while i<=sqrt(10000000000):
if x(i*i):
p.append(i*i)
i+=1
return p
def srch(sr,a,b):
c=0
for i in sr:
if i>=a and i<=b:
c+=1
if i>b:
break
return c
if __name__=='__main__':
ar=[1, 4, 9, 49, 100, 144, 400, 441, 900, 1444, 4900, 9409, 10000, 10404, 11449, 14400, 19044, 40000, 40401, 44100, 44944, 90000, 144400, 419904, 490000, 491401, 904401, 940900, 994009, 1000000, 1004004, 1014049, 1040400, 1100401, 1144900, 1440000, 1904400, 1940449, 4000000, 4004001, 4040100, 4410000, 4494400, 9000000, 9909904, 9941409, 11909401, 14010049, 14040009, 14440000, 19909444, 40411449, 41990400, 49000000, 49014001, 49140100, 49999041, 90440100, 94090000, 94109401, 99400900, 99940009, 100000000, 100040004, 100140049, 100400400, 101404900, 101949409, 104040000, 104919049, 110040100, 111049444, 114041041, 114490000, 144000000, 190440000, 194044900, 400000000, 400040001, 400400100, 404010000, 404090404, 409941009, 414000409, 414041104, 441000000, 449440000, 490091044, 900000000, 990990400, 991494144, 994140900, 1190940100, 1401004900, 1404000900, 1409101444, 1444000000, 1449401041, 1490114404, 1990944400, 4014109449L, 4019940409L, 4041144900L, 4199040000L, 4900000000L, 4900140001L, 4901400100L, 4914010000L, 4914991449L, 4941949401L, 4999904100L, 9044010000L, 9409000000L, 9409194001L, 9410940100L, 9900449001L, 9940090000L, 9994000900L, 9999400009L, 10000000000L]
t=int(input())
for xx in range(t):
a,b=raw_input().split()
a=int(a)
b=int(b)
print srch(ar,a,b)