#160. 列表元素平方
列表元素平方
Square List Elements
Background
Congcong is learning to process list data. He encountered a basic problem that requires performing a simple mathematical operation on each number in a list.
Problem Description
Given a list of integers, return a new list where each integer is replaced by its square.
Input Format
Input is given from Standard Input in the following format.
The input consists of a single line representing a list of integers. The integers in the list are space-separated and enclosed in square brackets
[]. If the list is empty, the input is[].
Output Format
Output to Standard Output in the following format.
The output consists of a single line representing the processed list of integers. The integers in the list are comma-separated, followed by a space, and enclosed in square brackets
[]. If the list is empty, the output is[].
Sample
[1 2 3]
[1, 4, 9]
[6 8 -6 -8 1]
[36, 64, 36, 64, 1]
[]
[]
Sample Explanation
Sample 1: The input list is [1 2 3]. Squaring each element yields [1*1, 2*2, 3*3], which is [1, 4, 9].
Sample 2: The input list is [6 8 -6 -8 1]. Squaring each element yields [36, 64, 36, 64, 1].
Sample 3: An empty input list [] returns an empty list [].
Constraints
Time limit: 1 second. Memory limit: 1024 KiB for each test case.