Simple Addition#1517

Simple Addition

1 Sekunde
128 Megabyte
Leicht

Let's define the recursive function :

F(n) = \begin{cases} n~\%~10,~n~\%~10 > 0 \\ 0, n = 0\\ F(n / 10), \text{otherwise} \end{cases}

Let's define the function S(p, q) as follows:

S(p, q) = \sum_{i=p}^{q} F(i)

Given values and , calculate S(p, q).

Eingabe

The input consists of several test cases. Each line contains two non-negative integers and (p \leq q). and are -bit signed integers. The last line contains two negative integers and should not be processed.

Ausgabe

For each pair and , output the value of S(p, q) on a single line.

Beispiele

Beispiel 1

Loading
Loading