#P8615. Concatenated Square Numbers

    ID: 21781 Type: Default 1000ms 256MiB

Concatenated Square Numbers

Concatenated Square Numbers

Given two integers L and R, find all numbers in the interval [L, R] that can be split into two parts such that both parts are non-empty, do not have leading zeros, and each part is a perfect square. For example, 49 can be split into 4 and 9, both of which are perfect squares, so 49 is a concatenated square number. Similarly, 169 can be split as 16 and 9, making it a concatenated square number as well.

Note that a split like that of 100 into 1 and 00 is invalid because numbers with leading zeros (like 00) are not considered valid squares.

Your task is to output all concatenated square numbers in ascending order within the given interval.

inputFormat

The input consists of a single line containing two integers L and R (1 ≤ L ≤ R ≤ 109), representing the inclusive range to search for concatenated square numbers.

outputFormat

Output all the found concatenated square numbers in ascending order, separated by a space. If no such number exists, output an empty line.

sample

1 200
49 169