#C13357. Squares and Cubes Dictionaries

    ID: 42886 Type: Default 1000ms 256MiB

Squares and Cubes Dictionaries

Squares and Cubes Dictionaries

You are given a list of integers. Your task is to construct two dictionaries:

  • The squares_dict where each key is an integer from the list and its corresponding value is the square of that integer.
  • The cubes_dict where each key is an integer from the list and its corresponding value is the cube of that integer.

Note that the output should be printed in the order of the keys in ascending order. In other words, if the list contains elements, you should sort them and then print the dictionaries. In the output, print the squares_dict on the first line and the cubes_dict on the second line. Each dictionary is printed as a sequence of key-value pairs in the format key:value separated by a single space.

For example, if the input is 4 followed by 1 2 3 4, then the squares dictionary will be {1: 1, 2: 4, 3: 9, 4: 16} and the cubes dictionary will be {1: 1, 2: 8, 3: 27, 4: 64}.

inputFormat

The first line of input contains an integer n, representing the number of elements in the list. The second line contains n space-separated integers.

outputFormat

Print two lines. The first line should contain the key-value pairs of the squares dictionary in ascending order of keys, formatted as 'key:value' separated by spaces. The second line should contain the key-value pairs of the cubes dictionary in the same format.## sample

4
1 2 3 4
1:1 2:4 3:9 4:16

1:1 2:8 3:27 4:64

</p>