#C923. Zigzag Conversion

    ID: 53300 Type: Default 1000ms 256MiB

Zigzag Conversion

Zigzag Conversion

Given a string s and an integer numRows, convert s into a zigzag pattern on numRows rows and then read the pattern line by line.

The zigzag pattern is created by writing the characters of s in a down-and-up diagonal fashion across rows. For example, when \(s = \texttt{PAYPALISHIRING}\) and \(numRows = 4\), the zigzag pattern looks like:

P     I     N
A   L S   I G
Y A   H R
P     I

Reading line by line, the output is PINALSIGYAHRPI.

If numRows is 1 or greater than or equal to the length of s, the output is the original string.

inputFormat

The input consists of two lines read from standard input:

  1. The first line contains the string s.
  2. The second line contains the integer numRows.

Both inputs are guaranteed to be valid.

outputFormat

Output a single line containing the string obtained after converting s into its zigzag pattern.

## sample
PAYPALISHIRING
4
PINALSIGYAHRPI