#P16267. [蓝桥杯 2026 省 Python B 组] 位数求和
[蓝桥杯 2026 省 Python B 组] 位数求和
Problem Description
Xiao Lan has recently been studying interval statistics problems.
Given a sequence of length , in the original problem, you need to compute
$$\sum_{l=1}^{n} \sum_{r=l}^{n} (r - l + 1) \max_{l \leq i \leq r} a_i$$That is, for every interval in the sequence, take the interval length and the interval maximum , multiply them, and sum the results over all intervals.
However, Xiao Lan feels that directly using the interval length is a bit monotonous, so he makes a small modification to this problem.
He defines a function to be the number of digits of the integer in its decimal representation. For example:
,
.
Now, for each interval , Xiao Lan no longer uses the interval length itself, but uses the number of digits of the interval length, . Therefore, he wants you to compute the value of the following expression:
$$\sum_{l=1}^{n} \sum_{r=l}^{n} f(r - l + 1) \max_{l \leq i \leq r} a_i$$Since the answer may be very large, you only need to output the result modulo .
Input Format
The input consists of two lines.
The first line contains a positive integer , representing the length of the sequence.
The second line contains positive integers , representing the given sequence.
Output Format
Output one line containing an integer, representing $\sum_{l=1}^{n} \sum_{r=l}^{n} f(r - l + 1) \max_{l \leq i \leq r} a_i$ modulo .
5
1 2 3 4 5
55
10
1 2 3 4 5 6 7 8 9 10
395
Hint
Constraints
For of the testdata, .
For of the testdata, .
For all testdata, , .
Translated by ChatGPT 5