fork(2) download
  1. def powm(i):
  2. j = 10
  3. a = 1
  4. while i:
  5. if i % 2:
  6. a = a * j
  7. i /= 2
  8. j *= j
  9. return a
  10.  
  11.  
  12. def power(n, i):
  13. m = powm(i)
  14. y = 1
  15. x = 2
  16. while n:
  17. if n % 2 == 1:
  18. y = y * x % m
  19. x = x * x % m
  20. n /= 2
  21. return y
  22.  
  23. mylist = []
  24. mylist.append(power(36, 2))
  25. n = mylist[0]
  26. for i in range(3, 170):
  27. p = power(n, i)
  28. #print p
  29. if p != n:
  30. mylist.append(p)
  31. n = p
  32.  
  33. t = input()
  34. while t:
  35. x = raw_input().split(" ")
  36. a = int(x[0])
  37. b = int(x[1])
  38. i = 0
  39. #while i <= 150:
  40. # print mylist[i]
  41. # i += 1
  42. #print power(8719476736,14)
  43. while mylist[i] < a:
  44. i += 1
  45. ans = 0
  46. while mylist[i] <= b:
  47. i += 1
  48. ans += 1
  49. print ans
  50. t -= 1
  51.  
Success #stdin #stdout 0.41s 7856KB
stdin
5
36 36
100 500
1 500
500 1000
1 1000000000000000
stdout
1
0
1
1
13