cswork / OA打开练习工作台

ReevoOA #1

Compression (Run-Length Encoding)

估计简单可在线判题

考点(AI 标注)字符串

Merge adjacent runs of the same letter from left to right: a run of length 1 outputs only the letter, and a run longer than 1 outputs the letter followed by the run length.

输入格式

One line containing a non-empty string of lowercase letters, length ≤100000.

输出格式

Output the compressed result.

样例 1

输入:

aabbccca

输出:

a2b2c3a

样例说明

Derive a linear scan/dynamic programming solution directly from the problem rules; the examples have been checked one by one against an independently built oracle.