Cool pairs P24413


Statement
 

pdf   zip

In this problem, we will say that a pair of integer numbers (x,y)(x, y) is cool if y=x+1y = x + 1, and both xx and yy are perfect squares or perfect cubes. For instance, (8,9)(8, 9) is a cool pair, because xx is a perfect cube (8=238 = 2^3) and yy is a perfect square (9=329 = 3^2). As another example, (0,1)(0, 1) is a cool pair as well (a bit special, since 0 and 1 are perfect squares and also perfect cubes).

Given an interval [,r][\ell, r], how many cool pairs does it contain?

Input

Input consists of several cases, each one with \ell and rr. Assume 0<r10180 \le \ell < r \le 10^{18}.

Output

For every case, print the number of cool pairs with xx and yy inside [,r][\ell, r].

Public test cases
  • Input

    0 8
    0 9
    1 15
    999999999999999999 1000000000000000000
    

    Output

    1
    2
    1
    0
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Official solutions
    C++
    User solutions
    C++