经典计数问题,注意0的判断 所以要引入前导0标记
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define int long long
const int N = 1e5+10;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int qmi(int a,int b,int mod){int res=1;while(b){if(b&1)res=res*a%mod;b>>=1;a=a*a%mod;}return res;}
int n,q,m;
int dp[35][35];
int ans[N];
int digit1,num1;
int a[N];
int dfs(int len,int s,int limit,int lead){
if(s>num1)return 0;
if(!len)return s==num1;
if(!lead&&!limit&&~dp[len][s])return dp[len][s];
int up = limit?a[len]:9;
int res = 0;
for(int i=0;i<=up;++i){
if(i==digit1){
if(!digit1&&lead)res+=dfs(len-1,s,limit&&i==up,lead&&i==0);
else res+=dfs(len-1,s+1,limit&&i==up,lead&&i==0);
}
else res+=dfs(len-1,s,limit&&i==up,lead&&i==0);
}
return limit?res:(lead?res:dp[len][s] = res);
}
int cal(int x){
memset(dp,-1,sizeof dp);
int len = 0;
while(x){a[++len] = x%10;x/=10;}
return dfs(len,0,1,1);
}
void solve()
{
int l,r;
cin>>l>>r;
for(int digit=0;digit<=9;++digit){
for(int num=0;num<=12;++num){
digit1 = digit;
num1 = num;
ans[digit]+=(cal(r)-cal(l-1))*num1;
}
}
for(int i=0;i<=9;i++)cout<<ans[i]<<" ";
}
signed main()
{
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int _;
//cin>>_;
_ = 1;
while(_--)solve();
return 0;
}