#C12447. Square of Positive Integers
Square of Positive Integers
Square of Positive Integers
Given a list of values, your task is to compute the square of every positive integer from the list and output them in the same order they appear. If any element in the list is not an integer, your program should output an error message: ValueError: All elements of the input list must be integers.
The input is provided via standard input (stdin) with the following format:
- The first line contains an integer n, representing the number of elements in the list.
- If n > 0, the second line contains n tokens separated by spaces. Each token is supposed to be an integer.
Your program should read the input, process it, and output the squares of all positive integers (i.e., strictly greater than zero) to standard output (stdout), separated by a single space. If there are no positive integers, output an empty line.
If any token cannot be parsed as an integer, the program must immediately output the exact error message below and terminate:
ValueError: All elements of the input list must be integers.
The mathematical operation involved is squaring an integer, which can be denoted using the LaTeX format as \(x^2\).
inputFormat
The first line contains an integer \(n\) (the number of elements). If \(n > 0\), the second line contains \(n\) space-separated tokens representing the list elements.
outputFormat
If the input list is valid, output a single line with the squares of all positive integers (greater than zero) from the list, separated by spaces. If the list has no positive integers, output an empty line. If any element is not an integer, output exactly:
ValueError: All elements of the input list must be integers.
## sample5
1 -2 3 0 4
1 9 16