False induction P52248


Statement
 

pdf   zip

thehtml

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 ≤ xy ≤ 1018 − 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.

Public test cases
  • Input

    1000 9999
    2025 2025
    2000 2024
    2026 3000
    1000000000 9999999999
    322132944245434624 322132944245434624
    

    Output

    3
    1
    0
    0
    4
    1
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Salvador Roura
    Original language
    Spanish
    Other languages
    Spanish
    Official solutions
    C++
    User solutions
    C++