#P4942. Remainder of Concatenated Sequence
Remainder of Concatenated Sequence
Remainder of Concatenated Sequence
Consider the number formed by concatenating all integers from l to r in order, denoted as \( \overline{l(l+1)(l+2)\ldots (r-1)r} \). For example:
- For \( l=2, r=5 \), the number is \( 2345 \).
- For \( l=8, r=12 \), the number is \( 89101112 \).
Your task is to compute the remainder when this concatenated number is divided by 9.
Note: Even though the concatenated number could be very large, you can use the property that a number is congruent to the sum of its digits modulo 9.
inputFormat
The input consists of two integers l and r separated by a space.
outputFormat
Output the remainder when the concatenated number ( \overline{l(l+1)(l+2)\ldots (r-1)r} ) is divided by 9.
sample
2 5
5