#111. 按模式生成数字序列

    ID: 111 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatArray-3gesp2循环嵌套模拟

按模式生成数字序列

Generate Sequence

Background

Congcong enjoys playing with number sequences. One day, he came up with an interesting sequence generation rule and wants you to help him implement it.

Problem Description

Given a non-negative integer n0n \ge 0, create an array with the pattern $\{1, \quad 1, 2, \quad 1, 2, 3, \quad \dots \quad 1, 2, 3, \dots, n\}$ (spaces added to show the grouping). Note that the length of the array will be 1+2+3++n1 + 2 + 3 + \dots + n, which is known to sum to exactly nimes(n+1)/2n imes (n + 1) / 2.

Input Format

Input is given from Standard Input in the following format.

An integer nn.

Output Format

Output is printed to Standard Output in the following format.

An integer array generated according to the pattern described in the problem.

Sample

3
[1, 1, 2, 1, 2, 3]
4
[1, 1, 2, 1, 2, 3, 1, 2, 3, 4]
2
[1, 1, 2]

Sample Explanation

When n=3n=3, the sequence consists of three parts: the first part is {1}\{1\}, the second part is {1,2}\{1, 2\}, and the third part is {1,2,3}\{1, 2, 3\}. Concatenating them yields [1,1,2,1,2,3][1, 1, 2, 1, 2, 3].

Constraints

Time limit: 1 second per test case. Memory limit: 1024 KiB per test case.