#K85902. Decorated String Creator
Decorated String Creator
Decorated String Creator
You are given a base string S and a non-negative integer N. Your task is to construct a new string by repeating S exactly N times. However, every second repetition (i.e. the 2nd, 4th, etc.) should be the reverse of S. The resulting strings are then joined together by hyphens.
For example:
- If S = "ABC" and N = 5, then the output should be "ABC-CBA-ABC-CBA-ABC".
- If S = "xy" and N = 3, then the output should be "xy-yx-xy".
If N is 0, output an empty string.
Note: Every second repetition is reversed.
inputFormat
The input consists of two lines:
- The first line contains the base string S.
- The second line contains a non-negative integer N, which is the number of repetitions.
outputFormat
Output the decorated string as described. There should be no extra spaces or newlines.
## sampleABC
5
ABC-CBA-ABC-CBA-ABC