#d2666. 数位计算

数位计算

Digit Counting

Problem Description

Given an integer nn, solve the following problem:

Let f(x)=f(x) = the number of positive integers that do not exceed xx and have the same number of digits as xx.

Compute f(1)+f(2)+⋯+f(n)f(1) + f(2) + \dots + f(n), modulo 998244353998244353.

Input Format

One integer NN.

Output Format

One integer — the answer to the problem above, modulo 998244353998244353.

Sample Input 1

16

Sample Output 1

73

Sample Explanation

For each xx from 11 to 99, the positive integers not exceeding xx with the same number of digits as xx are 1,2,…,x1, 2, \dots, x; hence f(1)=1,f(2)=2,…,f(9)=9f(1) = 1, f(2) = 2, \dots, f(9) = 9. For each xx from 1010 to 1616, they are 10,11,…,x10, 11, \dots, x; hence f(10)=1,f(11)=2,…,f(16)=7f(10) = 1, f(11) = 2, \dots, f(16) = 7. The answer is therefore 7373.

Sample Input 2

238

Sample Output 2

13870

Sample Input 3

999999999999999999

Sample Output 3

762062362

Constraints

For all data, 1≤N<10181 \leq N < 10^{18}, and NN is an integer.