#P7682. Cherry Harvesting
Cherry Harvesting
Cherry Harvesting
Lana lives in a happy little village. Along the main street, there is a row of cherry trees. The trees are numbered with consecutive integers starting from \(1\). After extensive research, Lana noticed that the number of cherries on a tree is uniquely determined by its number.
For each tree, consider the decimal representation of its number. Split the number into groups of consecutive identical digits. For each group with digit \(d\) (note that \(d\) is the unique digit in the group) and group length \(L\), the contribution of that group to the cherry count is given by \(d \times L^2\). The sum of contributions of all groups gives the total number of cherries on that tree.
For example, consider the tree numbered \(77744007\). Its decimal representation forms 4 groups: \(777\), \(44\), \(00\), and \(7\). Thus, its cherry count is computed as follows: \[ 7\times3^2 + 4\times2^2 + 0\times2^2 + 7\times1^2 = 7\times9 + 4\times4 + 0\times4 + 7\times1 = 63 + 16 + 0 + 7 = 86. \]
During cherry picking season, the villagers agree to pluck cherries from all trees whose numbers lie in the interval \([a, b]\). Your task is to calculate the total number of cherries harvested from the trees in this range.
inputFormat
The input consists of a single line containing two integers \(a\) and \(b\) (with \(1 \leq a \leq b\)). They specify the inclusive range of tree numbers from which cherries are to be harvested.
outputFormat
Output a single integer representing the total number of cherries harvested from all trees numbered between \(a\) and \(b\) (inclusive).
sample
1 9
45