#C14992. Filter Perfect Squares Greater Than a Threshold

    ID: 44702 Type: Default 1000ms 256MiB

Filter Perfect Squares Greater Than a Threshold

Filter Perfect Squares Greater Than a Threshold

Given a list of integers and an integer threshold, the task is to output all numbers from the list which are perfect squares and strictly greater than the specified threshold. A number n is a perfect square if there exists an integer k such that \(k^2 = n\).

For example, if the threshold is 10 and the list is [1, 4, 9, 14, 16, 20, 25, 30], then the numbers 16 and 25 are the only perfect squares greater than 10.

The program should read input from stdin and write the result to stdout, where the output will be a space-separated sequence of qualifying integers. If no numbers qualify, output an empty line.

inputFormat

The program receives input from standard input in the following format:

  • The first line contains one integer: the threshold.
  • The second line contains one integer: n, the number of elements in the list.
  • The third line contains n space-separated integers representing the list of numbers.

outputFormat

Output a single line to standard output containing the qualifying integers (that are perfect squares and greater than the threshold) separated by spaces. If no integer qualifies, output an empty line.

## sample
10
8
1 4 9 14 16 20 25 30
16 25

</p>