#C6370. Treasure Sequence
Treasure Sequence
Treasure Sequence
You are given a list of treasure distances and a number M representing the count of treasures. Some of these distances correspond to treasures located at perfect square positions. Your task is to filter out the distances that are perfect squares and output them in ascending order. If no perfect square distances exist, output "No treasures found".
The formula to determine if a number \(x\) is a perfect square is:
[ \sqrt{x} \text{ is an integer} \quad \Longleftrightarrow \quad \lfloor \sqrt{x} \rfloor^2 = x ]
Note: The input/output operations must be conducted using standard input (stdin) and standard output (stdout).
inputFormat
The input is read from standard input (stdin) in two lines:
- The first line contains one integer \(M\), the number of treasures.
- The second line contains \(M\) space-separated integers representing the distances of the treasures.
outputFormat
Print to standard output (stdout) the distances that are perfect squares sorted in ascending order, separated by a space. If no such distances exist, output "No treasures found".
## sample7
1 4 8 9 15 16 25
1 4 9 16 25