Cool pairs

In this problem, we will say that a pair of integer numbers (x, y) is
cool if y = x + 1, and both x and y are perfect squares or perfect
cubes. For instance, (8, 9) is a cool pair, because x is a perfect cube
(8 = 2³) and y is a perfect square (9 = 3²). As another example, (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], how many cool pairs does it contain?

Input

Input consists of several cases, each one with ℓ and r. Assume
0 ≤ ℓ < r ≤ 10¹⁸.

Output

For every case, print the number of cool pairs with x and y inside
[ℓ, r].

Problem information

Author: Salvador Roura

Generation: 2026-01-25T10:21:39.406Z

© Jutge.org, 2006–2026.
https://jutge.org
