Computational ethnography
InterviewTime limit1sMemory limit512 MB
Count the numbers from A to B whose digit reversal is also a perfect square, where both the number and its reversal are squares and the reversal has no leading zero.
- Level
Easy3 of 10
- Topics
- Brute force, Math
- Solved
- No attempts yet
Problem
The natives of Island L write numbers backwards: the most significant digit of a number is written last. For example, is written as .
Petya, a novice ethnographer and mathematician, studies square numbers and the culture of Island L. He found that some numbers are perfect squares both when read normally and when read the way the natives write them. For example, , and the native form . Petya calls such numbers interesting.
Petya wants to know how many interesting numbers lie between and , inclusive.
Input
The first line contains the integer . The second line contains the integer . ()
Output
Print the number of interesting numbers from to .
Hint
In the first input, the interesting numbers are , , , , , , , , , and . The natives do not write leading zeros, so is not interesting.