Explanation: Take 1 as an example to enumerate 1-1,10-19,100-199, .... Every time from the right boundary to find the quotient K, according to the formula to find the nearest point to the left to make the quotient for k+1, if d=1, then the left point does not exist K+1,ans can add k*d distance, and then skip the distance.
Code:
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string.h >
#include <queue>
using namespace std;
typedef long long LL;
const int MX = 1E5+10;
int n,m,len,mid;
ll Cnt[11];
Char str[15];
ll get_sum (int l,int r,int x) {
ll ans = 0;
r = min (r,x);
int k = X/r,mod = x%r;
while (1) {
int d = (r-mod)/(k+1);
if (d* (k+1) <r-mod) d++;
if (r-d<l) break;
Ans + = k*d;
MoD = (k*d+mod)% (r-d);
R = r-d;
K = d==1? x/r:k+1;
}
ans+= (r-l+1) *k;
return ans;
}
void work (Int. X,int v) {for
(int i=1;i<10;i++) {
int rode = 1;
while (1ll*i*rode<=x) {
int rr = i*rode+rode-1;
Cnt[i] + = V*get_sum (i*rode,rr,x);
rode*=10
;
}}} int main () {while
(~scanf ("%d%d", &n,&m)) {
memset (cnt,0,sizeof (CNT));
Work (m,1);
Work (n-1,-1);
for (int i=1;i<10;i++)
printf ("%lld\n", Cnt[i]);
}
return 0;
}