#C14720. Process Numbers: Even Squares and Odd Cubes

    ID: 44401 Type: Default 1000ms 256MiB

Process Numbers: Even Squares and Odd Cubes

Process Numbers: Even Squares and Odd Cubes

You are given a list of integers. Your task is to process the list in a single pass and produce two results:

  • even_squares: A list of squares of all even numbers.
  • odd_cubes: A list of cubes of all odd numbers.

The order of the numbers in each result must match the order they appear in the input.

Mathematically, for each integer \(x\) in the input:

  • If \(x\) is even, include \(x^2\) in even_squares.
  • If \(x\) is odd, include \(x^3\) in odd_cubes.

inputFormat

The input is given via stdin in the following format:

  1. The first line contains a single integer \(n\), denoting the number of elements in the list.
  2. The second line contains \(n\) space-separated integers.

If \(n = 0\), the second line will be empty.

outputFormat

Print the results to stdout in two lines:

  • The first line should contain the squares of the even numbers separated by a space. If there are no even numbers, print an empty line.
  • The second line should contain the cubes of the odd numbers separated by a space. If there are no odd numbers, print an empty line.
## sample
5
1 2 3 4 5
4 16

1 27 125

</p>