P29681 [洛谷] [COCI2008-2009#5] TRESNJA
提高-
题目描述

Problem Description

Lana lives in a joyful small village. Along the main street, there is a row of cherry trees. Lana noticed that each tree is numbered with consecutive integers starting from 1. After extensive research, Lana found that the tree number uniquely determines the number of cherries on the tree. For a tree, consider splitting the tree number into groups of consecutive digits. For each group, multiply the unique digit in that group by the square of the group's length. Summing these values gives the total number of cherries on the tree. For example, in a tree numbered 77744007, we split the number into groups: 777, 44, 00, and 7. Thus, the number of cherries on the tree numbered 77744007 is \(7 \times 3^2 + 4 \times 2^2 + 0 \times 2^2 + 7 \times 1^2 = 86\).

It's time to pick cherries, and the villagers agree to pick all the cherries from the trees numbered within the interval \([a, b]\). Now, please write a program to calculate the total amount of cherries to be picked.

Input Format

The input consists of a single line with two integers \(a\) and \(b\), representing the starting and ending points of the trees from which cherries can be picked.

Output Format

The output should be a single line with one integer, representing the total number of cherries that can be picked.

Sample Input and Output

Sample Input #1

1 9

Sample Output #1

45

Sample Input #2

100 111

Sample Output #2

68

Sample Input #3

7774407 7774407

Sample Output #3

86

Notes

[Data Range]

For all data, \(1 \leqslant a \leqslant b \leqslant 10^{15}\).

[Problem Source]

This problem is from COCI 2008-2009 CONTEST 5 T5 TRESNJA, configured with the original data. Full score is 120 points.

Provided by Eason_AC for translation and arrangement.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
1 9
样例输出
45