UberOA #58
Repeatedly Add Consecutive Equal Digits
估计简单可在线判题
考点(AI 标注)字符串模拟/实现
In each round, simultaneously replace every group of consecutive identical digits with the decimal representation of the sum of its digits. Repeat until no two adjacent digits are the same. The input is a string, and leading 0s are kept; several 0s sum to a single 0.
This site has made the standard input and output explicit.
输入格式
One line containing a non-empty digit string. On this site the length is 1..2000.
输出格式
Output the final digit string.
样例 1
输入:
999433
输出:
2746
样例 2
输入:
44488366664
输出:
1216328
样例 3
输入:
0044886
输出:
084
样例说明
Example 1: 999→27 and 33→6 give 2746, which is already stable. Example 2: after the first round, 12163244 still contains 44, so it continues to 1216328; the original site stopped too early. Example 3: 0044886→08166→08112→0822→084, so the answer is 084, with the leading 0 kept.