eolymp
bolt
Try our new interface for solving problems
Problems

Simple Addition

Simple Addition

Let's define the next recursive function $F(n)$, where $$ F(n) = \begin{cases} n~\%~10,~n~\%~10 > 0 \\ 0, n = 0\\ F(n / 10), otherwise \end{cases} $$ Let's define the function $S(p, q)$ as follows: $$ S(p, q) = \sum_{i=p}^{q} F(i) $$ In this problem you have to calculate $S(p, q)$ on given values of $p$ and $q$. \InputFile Consists of multiple test cases. Each line contains two nonnegative integers $p$ and $q~(p \le q)$. $p$ and $q$ will fit in $32$ bit signed integer. Input is terminated by a line with two negative integers. This line should not be processed. \OutputFile For each pair $p$ and $q$ print the value $S(p, q)$ on a single line.
Time limit 1 second
Memory limit 128 MiB
Input example #1
1 10
10 20
30 40
-1 -1
Output example #1
46
48
52