#K15056. Squares of Unique Even Numbers

    ID: 24271 Type: Default 1000ms 256MiB

Squares of Unique Even Numbers

Squares of Unique Even Numbers

You are given a list of integers. Your task is to compute the square of each unique even number in the order in which they first appear in the list.

More formally, let the input list be \(a_1, a_2, \dots, a_n\). Traverse the list and for each even number \(a_i\) that has not been encountered before, output \(a_i^2\). Use the order of first occurrence.

For example, consider the list: [4, 4, 7, 2, 3, 8, 6, 6, -2, -8, -8]. The first even number is 4 so output \(4^2 = 16\). The next unique even is 2 (\(2^2 = 4\)), then 8 (\(8^2 = 64\)), then 6 (\(6^2 = 36\)), then -2 (\((-2)^2 = 4\)) and finally -8 (\((-8)^2 = 64\)). Thus, the final output is: [16, 4, 64, 36, 4, 64].

If there are no even numbers in the list, output an empty line.

inputFormat

The input is read from standard input (stdin) and has the following format:

n
x1 x2 x3 ... xn

Where:

  • \(n\) is an integer representing the number of elements in the list.
  • \(x1, x2, \dots, xn\) are the space-separated integers.

outputFormat

Print on a single line the squared values of each unique even number in the order of their first occurrence, separated by a single space. If no even number exists, output an empty line.

## sample
11
4 4 7 2 3 8 6 6 -2 -8 -8
16 4 64 36 4 64