题目描述
Problem Description
Takahashi has a certain string $ s $. Interested in shortening the representation of strings, Takahashi decided to try the following compression method:
- Divide the string $ s $ into substrings where the same character appears consecutively. (Divide)
- Convert each divided substring into a new string consisting of the character and the length of its consecutive occurrence. (Convert)
- Finally, concatenate the converted substrings in order from the beginning. (Concatenate)
Applying this compression method to the string aabbbaad results in:
- Dividing
aabbbaadintoaabbbaad - Converting
aabbbaadintoa2b3a2d1 - Concatenating
a2b3a2d1intoa2b3a2d1
Thus, we obtain a2b3a2d1.
Given the string $ s $, write a program to find the compressed string using the above method on behalf of Takahashi.
Input Format
The input is given from the standard input in the following format:
$ s $
- The string to be compressed $s\ (1\ ≦\ |s|\ ≦\ 1,000)$ is given ($ |s| $ represents the length of the string $ s $).
- It is guaranteed that $ s $ is a string consisting of lowercase English letters.
Output Format
Output the compressed string created from $ s $ to the standard output.
Do not forget the trailing newline.
Sample Input and Output
Sample Input #1
aabbbaad
Sample Output #1
a2b3a2d1
Sample Input #2
aabbbbbbbbbbbbxyza
Sample Output #2
a2b12x1y1z1a1
Sample Input #3
edcba
Sample Output #3
e1d1c1b1a1
Notes/Hints
Sample Explanation 1
This is the example given in the problem statement.
Sample Explanation 2
Lengths are represented in decimal notation.
Sample Explanation 3
The compressed result may be longer than the original string.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分