The DP (I, J, K) represents the total I bit, the highest bit is J, and the number of K occurrences. preprocessed.
Differential answer, for 0~x answer, from low to high to discuss
------------------------------------------------------------------------------
#include <bits/stdc++.h>using namespace std;typedef long Long ll;const int MAXN = +;const int N = ten;const int L = +; ll DP[MAXN][MAXN][MAXN], ANS[2][MAXN];void init () {memset (DP, 0, sizeof DP);ll power = 1;for (int i = 0; i < N; i++) dp[1][i][i] = 1;for (int i = 2; i < L; i++) {power *= 10LL;For (int j = 0; J < N; J + +) {Dp[i][j][j] + + power;for (int k = 0; k < N; k++)for (int l = 0; l < N; l++)Dp[i][j][l] + = dp[i-1][k][l];    }}}//[0, X]void Work (ll x, int p) {if (x < 0) return;int S[MAXN], n = 0;if (!x) s[++n] = 0;For (; x; x/=) s[++n] = x%;ll cnt = 1, power = 1;for (int i = 1; I <= n; i++) {Ans[p][s[i]] + = CNT;cnt + = power * S[i];power *= 10LL;For (int j = (i = = N && i! = 1); J < S[i]; j + +)for (int k = 0; k < N; k++) ans[p][k] + = dp[i][j][k];For (int j = (i! = 2); J < N; J + +)for (int k = 0; k < N; k++)Ans[p][k] + = dp[i-1][j][k];}}int main () {init ();ll A, b; Cin >> a >> b;Work (A-1, 0); work (b, 1);for (int i = 0; i < N; i++) {if (i) Putchar (");printf ("%lld", Ans[1][i]-ans[0][i]);}return 0;}
------------------------------------------------------------------------------
   1833: [Zjoi2010]count digit count time limit: 3 Sec Memory Limit:  
 Submit: 1995 Solved: 880 
[Submit] [Status] [Discuss]  Description given two positive integers a and B, for all integers in [a, b], how many times each digital (digit) appears. Only one line of two integers a, B, is included in the input file, meaning as described above. The output file contains a row of 10 integers representing the number of times that 0-9 appears in [A, b]. Sample Input1 99
Sample Output9 20 20 20 20 20 20 20 20 20
HINT
30% of the data in,a<=b<=10^6;
100% of the data, a<=b<=10^12.
Source
Day1
Bzoj 1833: [Zjoi2010]count Digital Count (DP)