title: Interesting Powers Of 2 - algorithm/ Math (from Hackerrank ACM APC)
body: <p>I came across a problem from a recent competition. 
  I was unable to figure out a solution, and no editorial for the question is yet available.</p>
  
  <blockquote>
    <p><a href="https://www.hackerrank.com/contests/apc/challenges/interesting-powers-of-two" rel="nofollow">Question Link</a></p>
  </blockquote>
  
  <p>I am quoting the problem statement here also in case the link doesn't work.</p>
  
  <p>Find the number of integers n which are greater than or equal to A and less than or equal to B (A&lt;= n &lt;=B) and the <strong>decimal representation of 2^n ends in n</strong>.</p>
  
  <p><strong>Ex:</strong> 2^36 = 68719476736  which ends in “36”.</p>
  
  <p><strong>INPUT</strong></p>
  
  <p>The first line contains an integer T i.e. number of test cases. T lines follow, each containing two integers A and B.</p>
  
  <p><strong>Constraints</strong></p>
  
  <pre><code>1 &lt;= T &lt;= 10^5
  
  A&lt;=B
  
  A,B &lt;= 10^150
  </code></pre>
  
  <p><strong>OUTPUT</strong></p>
  
  <p>Print T lines each containing the answer to the corresponding testcase.</p>
  
  <hr>
  
  <p><strong>Sample Input</strong></p>
  
  <pre><code>2
  36 36
  100 500
  </code></pre>
  
  <p><strong>Sample Output</strong></p>
  
  <pre><code>1
  0
  </code></pre>