UberOA #58
Repeatedly Add Consecutive Equal Digits
Estimated EasyJudge-ready
Topics (AI-labelled)StringsSimulation
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.
Input
One line containing a non-empty digit string. On this site the length is 1..2000.
Output
Output the final digit string.
Example 1
Input:
999433
Output:
2746
Example 2
Input:
44488366664
Output:
1216328
Example 3
Input:
0044886
Output:
084
Example notes
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.
Editorial
Loading solution…