#K50277. Duplicate Characters
Duplicate Characters
Duplicate Characters
You are given a string s consisting of only lowercase letters and an integer n. Your task is to duplicate each character of the string exactly n
times and output the resulting string.
More formally, for each character \(c\) in the string \(s\), the output string should contain \(c\) repeated \(n\) times. For example, if \(s = "abc"\) and \(n = 3\), then the output should be "aaabbbccc".
Input Restrictions: The string will consist only of lowercase English letters. The integer n
is a positive integer.
inputFormat
The input is read from standard input (stdin) and consists of two lines:
- The first line contains a non-negative string
s
of lowercase letters. (Note:s
could be empty.) - The second line contains a positive integer
n
, indicating the number of times each character ins
should be duplicated.
outputFormat
Output a single line to standard output (stdout) containing the transformed string where each character in the input string is repeated n
times.
a
3
aaa