#P5257. [JSOI2013] 密码

[JSOI2013] 密码

Background

Will has a mysterious box. It is said that if someone can crack the password on the box, they can foresee the future (for example, know what the official solution of this problem looks like). Would you like to give it a try?

Problem Description

For an mm-digit decimal integer N = (n1n2n3nm)10N~=~(\overline{n_1 n_2 n_3 \dots n_m})_{10}, define g(N) = i=1mnig(N)~=~\sum_{i = 1}^{m} n_i.

Define the set $S_N~=~\{x~|~x~>~0,~g(x)~\leq~N,x~\text{ has no digit equal to } 0 \text{ in its decimal representation}\}$.

Given nn, compute

$$f(n)~=~\sum_{x \in S_n} \sum_{y \in S_n \land x < y} x~\times~y$$

Output the answer modulo 106+310^6+3.

Input Format

One line with a positive integer nn.

Output Format

One line with one integer, representing the result of the answer modulo 106+310^6 + 3.

2
35

Hint

Explanation for Sample Input/Output 1

Sn=1,2,11S_n={1, 2, 11}, so f(N) = 1×2+1×11+2×11 = 35f(N)~=~1 \times 2+1 \times 11+2 \times 11~=~35.


Constraints

For 100%100\% of the testdata, it is guaranteed that 3  n  10183~\leq~n~\leq~10^{18}.

Translated by ChatGPT 5