#P8245. [COCI 2013/2014 #3] PAROVI
[COCI 2013/2014 #3] PAROVI
Problem Description
Define the distance between two integers as the sum of the absolute differences of the digits in each corresponding position, denoted by . In particular, if and have different numbers of digits, pad the shorter one with leading zeros. For example:
- $\operatorname{dist}(4561,3278)=\left|4-3\right|+\left|5-2\right|+\left|6-7\right|+\left|1-8\right|=12$.
- $\operatorname{dist}(32,5678)=\left|0-5\right|+\left|0-6\right|+\left|3-7\right|+\left|2-8\right|=21$.
Now, given two integers , compute the sum of distances over all ordered pairs of integers within the interval . Since the answer may be very large, take it modulo .
Input Format
The input consists of one line containing two integers .
Output Format
Output one integer per line: the sum of distances over all ordered pairs of integers in , modulo .
1 5
40
288 291
76
1000000 10000000
581093400
Hint
[Sample 2 Explanation]
All distances between integer pairs in are:
- $\operatorname{dist}(288,289)=\operatorname{dist}(289,288)=1$.
- $\operatorname{dist}(288,290)=\operatorname{dist}(290,288)=9$.
- $\operatorname{dist}(288,291)=\operatorname{dist}(291,288)=8$.
- $\operatorname{dist}(289,290)=\operatorname{dist}(290,289)=10$.
- $\operatorname{dist}(289,291)=\operatorname{dist}(291,289)=9$.
- $\operatorname{dist}(290,291)=\operatorname{dist}(291,290)=1$.
Therefore, the sum of distances is .
[Constraints and Limits]
For of the testdata, .
For of the testdata, .
For all testdata, .
[Source]
This problem comes from COCI 2013-2014 CONTEST 3 T5 PAROVI, and follows the original testdata settings, with a full score of points.
Translated and整理 provided by Eason_AC.
Translated by ChatGPT 5