#t199. 行程长度编码
行程长度编码
Run-Length Encoding
Problem Description
In data compression, a common approach is run-length compression. For a string to be compressed, we can record in order each character and how many times it repeats consecutively. This compression works well when adjacent data repeats a lot. For example, if the string to be compressed is AAABBBBCBB, the compressed result is (A,3)(B,4)(C,1)(B,2). Of course, if adjacent characters repeat less, the compression is less efficient.
Now, given the input string, produce the case-insensitive compressed result (i.e. treat all lowercase letters as their corresponding uppercase letters).
Input Format
A string of length greater than and at most , consisting entirely of uppercase or lowercase letters.
Output Format
Output one line, the compressed result, in the form:
(A,3)(B,4)(C,1)(B,2)
That is, each pair of parentheses contains a character (all uppercase) and the number of consecutive occurrences, with no spaces anywhere.
Sample Input
aAABBbBCCCaaaaa
Sample Output
(A,3)(B,4)(C,3)(A,5)