#P9640. [SNCPC2019] Digit Mode

    ID: 8937 Type: RemoteJudge 3000ms 256MiB Tried: 0 Accepted: 0 Difficulty: 5 Uploaded By: Tags>2019O2优化数位 dp陕西XCPC

[SNCPC2019] Digit Mode

题目描述

Let m(x)m(x) be the mode\textit{mode} of the digits in decimal representation of positive integer xx. The mode is the largest value that occurs most frequently in the sequence. For example, m(15532)=5m(15532)=5, m(25252)=2m(25252)=2, m(103000)=0m(103000)=0, m(364364)=6m(364364)=6, m(114514)=1m(114514)=1, m(889464)=8m(889464)=8.

Given a positive integer nn, DreamGrid would like to know the value of (x=1nm(x))mod(109+7)(\sum\limits_{x=1}^{n} m(x)) \bmod (10^9+7).

输入格式

There are multiple test cases. The first line of the input contains an integer TT, indicating the number of test cases. For each test case:

The first line contains a positive integer nn (1n<10501 \le n < 10^{50}) without leading zeros.

It's guaranteed that the sum of n|n| of all test cases will not exceed 5050, where n|n| indicates the number of digits of nn in decimal representation.

输出格式

For each test case output one line containing one integer, indicating the value of (x=1nm(x))mod(109+7)(\sum\limits_{x=1}^{n} m(x)) \bmod (10^9+7).

题目大意

m(x)m(x) 是正整数 xx 在十进制中的 modemodemodemodexx 中最频繁出现的最大值。例如 $m(15532)=5,m(25252)=2,m(103000)=0,m(364364)=6,m(114514)=1,m(889464)=8$。

给定一个正整数 nn,DreamGrid 希望知道 (x=1nm(x))mod(109+7)(\sum\limits_{x=1}^n m(x)) \mod (10^9+7) 的值。

5
9
99
999
99999
999999
45
615
6570
597600
5689830