#20. 创建双倍长度数组

    ID: 20 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatArray-1gesp3一维数组

创建双倍长度数组

Create Double Length Array

Background

Congcong is currently learning about array operations. He encountered an interesting problem that requires creating a new array based on an existing one.

Problem Description

Given an integer array, return a new array with double the length where its last element is the same as the original array, and all the other elements are 00. The original array will be length 11 or more. Note: by default, a new integer array contains all 00's.

Input Format

Input is given from standard input in the following format.

An integer array, with elements separated by spaces.

Output Format

Output is printed to standard output in the following format.

A new integer array, with elements separated by commas and spaces.

Sample

[4 5 6]
[0, 0, 0, 0, 0, 6]
[1 2]
[0, 0, 0, 2]
[3]
[0, 3]

Sample Explanation

For the first sample, the original array is [4 5 6], with a length of 33. The new array's length should be 3×2=63 \times 2 = 6. The last element of the new array should be the same as the last element of the original array, which is 66, and all other elements should be 00. Thus, the new array is [0, 0, 0, 0, 0, 6].

Constraints

Time limit: 11 second. Memory limit: 10241024 KiB for each test case.