fork download
  1. lowerbound, upperbound = map(int, raw_input().split())
  2. c = 0
  3. for i in range(len(bin(lowerbound))-2, len(bin(upperbound))-1):
  4. s = ['1'] * i
  5. for j in range(len(s)-1):
  6. k = s[:]
  7. k[len(k)-1-j] = '0'
  8. k = int(''.join(k), 2)
  9. if (k<=upperbound) and (k>=lowerbound):
  10. c += 1
  11. print c
Success #stdin #stdout 0.01s 8976KB
stdin
72057594000000000 72057595000000000
stdout
26