P29353 [洛谷] [COCI2007-2008#3] TAJNA
普及
题目描述

Problem Description

Using a specific encryption algorithm.

Given the length of a string $n$, construct a matrix such that $r \times c = n$ and $r \leq c$ with $r$ being as large as possible.

Fill the given plaintext into this $r \times c$ matrix in a top-to-bottom, left-to-right order.

The ciphertext is obtained by outputting the characters from the matrix in a left-to-right, top-to-bottom order.

Given the plaintext, output the ciphertext.

Input Format

A single line containing a string representing the plaintext.

Output Format

A single line containing a string representing the ciphertext.

Sample Input and Output

Sample Input #1

bok

Sample Output #1

bok

Sample Input #2

koaski

Sample Output #2

kakosi

Sample Input #3

boudonuimilcbsai

Sample Output #3

bombonisuuladici

Notes

Sample 3 Explanation

Matrix Explanation

There are 16 characters, and for the matrix dimensions, options include $1 \times 16$, $2 \times 8$, and $4 \times 4$. Since $r$ should be as large as possible, we choose $4 \times 4$.

The matrix is filled as shown in the image.

Finally, output each character from the matrix in a left-to-right, top-to-bottom order.

Data Constraints

For 100% of the data, the input string consists only of lowercase letters and has a length not exceeding 100.

Notes

This problem is translated from COCI2007-2008 CONTEST #3 T3 TAJNA.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
bok
样例输出
bok