False induction

In the palace of the Caliph of Baghdad Beremiz had to face seven of the
greatest scholars of his time, each of which proposed a quiz. One of
them was simple:

“In mathematics, is it possible to deduce a false rule from true facts?”

This was the answer of Beremiz:

“Suppose that we want to know how to calculate the square root of a
number that has an even number of digits, and that we randomly choose
the numbers 2025, 3025 and 9801. After the calculations, the square root
of 2025 is 45, that of 3025 is 55, and that of 9801 is 99. But
20 + 25 = 45, 30 + 25 = 55, and 98 + 01 = 99, from which we could
wrongly deduce that the square root of a number can be calculated by
adding their left and right halves.”

Input

Input consists of several cases, each with two natural numbers x and y
with the same even number of digits. Assume 10 ≤ x ≤ y ≤ 10¹⁸ − 1.

Output

For every case, print how many numbers exist between x and y inclusively
such that their square root is exact and equal to the sum of the left
and the right halves of the number.

Problem information

Author: Unknown
Translator: Salvador Roura

Generation: 2026-01-25T11:10:00.117Z

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