当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

1782:Run Length Encoding

题目描述
Your task is to write a program that performs a simple form of run-length encoding, as described by the rules below.

Any sequence of between 2 to 9 identical characters is encoded by two characters. The first character is the length of the sequence, represented by one of the characters 2 through 9. The second character is the value of the repeated character. A sequence of more than 9 identical characters is dealt with by first encoding 9 characters, then the remaining ones.

Any sequence of characters that does not contain consecutive repetitions of any characters is represented by a 1 character followed by the sequence of characters, terminated with another 1. If a 1 appears as part of the sequence, it is escaped with a 1, thus two 1 characters are output.
输入解释
The input consists of letters (both upper- and lower-case), digits, spaces, and punctuation. Every line is terminated with a newline character and no other characters appear in the input.
输出解释
Each line in the input is encoded separately as described above. The newline at the end of each line is not encoded, but is passed directly to the output.
输入样例
AAAAAABCCCC
12344
输出样例
6A1B14C
11123124

该题目是Virtual Judge题目,来自 北京大学POJ

题目来源 Ulm Local 2004

源链接: POJ-1782

最后修改于 2020-10-29T06:13:57+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 30000