#P7682. [COCI 2008/2009 #5] TRESNJA
[COCI 2008/2009 #5] TRESNJA
Description
Lana lives in a happy little village. Along the main street there is a row of cherry trees. Lana noticed that each tree is numbered with consecutive integers starting from . After a lot of research, Lana discovered that a tree’s number uniquely determines how many cherries it has. For a given tree, split its number into groups of consecutive identical digits. For each group, multiply the unique digit in that group by the square of the group’s length. Add these values together to get the total number of cherries on the tree. For example, for the tree numbered , we split the number into groups: , , , and . Therefore, the number of cherries on the tree numbered is .
It is time to pick cherries. The villagers agreed to pick all cherries from the trees whose numbers are in the interval . Now you need to write a program to compute the total number of cherries that will be picked.
Input Format
The input contains only one line with two integers , representing the starting and ending tree numbers that can be picked.
Output Format
Output only one line with one integer, representing the total number of cherries that can be picked.
1 9
45
100 111
68
7774407 7774407
86
Hint
Constraints
For all testdata, .
Source
This problem is from COCI 2008-2009 CONTEST 5 T5 TRESNJA, using the original testdata configuration, with a full score of points.
Translated and整理 (zhengli) provided by Eason_AC.
Translated by ChatGPT 5
京公网安备 11011102002149号