102472: [AtCoder]ABC247 C - 1 2 1 3 1 2 1

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $300$ points

Problem Statement

We define sequences $S_n$ as follows.

  • $S_1$ is a sequence of length $1$ containing a single $1$.
  • $S_n$ ($n$ is an integer greater than or equal to $2$) is a sequence obtained by concatenating $S_{n-1}$, $n$, $S_{n-1}$ in this order.

For example, $S_2$ and $S_3$ is defined as follows.

  • $S_2$ is a concatenation of $S_1$, $2$, and $S_1$, in this order, so it is $1,2,1$.
  • $S_3$ is a concatenation of $S_2$, $3$, and $S_2$, in this order, so it is $1,2,1,3,1,2,1$.

Given $N$, print the entire sequence $S_N$.

Constraints

  • $N$ is an integer.
  • $1 \leq N \leq 16$

Input

Input is given from Standard Input in the following format:

$N$

Output

Print $S_N$, with spaces in between.


Sample Input 1

2

Sample Output 1

1 2 1

As described in the Problem Statement, $S_2$ is $1,2,1$.


Sample Input 2

1

Sample Output 2

1

Sample Input 3

4

Sample Output 3

1 2 1 3 1 2 1 4 1 2 1 3 1 2 1
  • $S_4$ is a concatenation of $S_3$, $4$, and $S_3$, in this order.

Input

题意翻译

我们按如下方式定义序列 $ S_n $: $ S_1 $ 只包含一个整数 $ 1 $。 $ S_n $ 为 $ S_{n - 1}, n, S_{n - 1} $ 构成的序列。 给定 $ n $,输出序列 $ S_n $。

Output

得分:300分

问题描述

我们定义如下序列$S_n$。

  • $S_1$是一个长度为1的序列,仅包含一个1。
  • $S_n$(n是一个大于等于2的整数)是由$S_{n-1}$、n和$S_{n-1}$按照这个顺序连接起来的序列。

例如,$S_2$和$S_3$定义如下。

  • $S_2$是按照$S_1$、2和$S_1$的顺序连接起来的,所以它是$1,2,1$。
  • $S_3$是按照$S_2$、3和$S_2$的顺序连接起来的,所以它是$1,2,1,3,1,2,1$。

给定$N$,打印整个序列$S_N$。


约束

  • $N$是一个整数。
  • $1 \leq N \leq 16$

输入

输入从标准输入按照以下格式给出:

$N$

输出

打印$S_N$,用空格隔开。


样例输入1

2

样例输出1

1 2 1

如问题描述中所述,$S_2$是$1,2,1$。


样例输入2

1

样例输出2

1

样例输入3

4

样例输出3

1 2 1 3 1 2 1 4 1 2 1 3 1 2 1
  • $S_4$是按照$S_3$、4和$S_3$的顺序连接起来的。

加入题单

算法标签: