P10312 [SHUPC 2024] Rail Fence Cipher

Description

The rail fence cipher (rail fence) is a very basic transposition cipher. We arrange the plaintext `Hello,World!` as follows: ``` H...o...r .e.l.,.o.l.! ..l...W...d ``` That is, we place the plaintext into a pattern like several `\/\/\/`, and then take out the characters row by row from left to right to form the ciphertext. For example, the first row is `Hor`, the second row is `el,ol!`, and the third row is `lWd`, so the final ciphertext is `Horel,ol!lWd`. If the ciphertext arranged in the above way has $h$ rows, then the height of this rail fence cipher is defined as $h$. Now you are given the height $h$ and a line of ciphertext string $s$. Please output one line containing the plaintext string $plain$.

Input Format

The first line contains an integer $h\ (2\le h \le10)$, which is the height of the cipher. The second line contains a string $s\ (1\le |s| \le 10^5)$, which is the ciphertext.

Output Format

Output a string $plain$, which is the plaintext.

Explanation/Hint

Translated by ChatGPT 5