数位DP模板
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll mem[110][110][2][2][2];
ll cal(ll start, ll finish, int t) {
string low = to_string(start);
string high = to_string(finish);
int n = high.size();
low = string(n - low.size(), '0') + low;
memset(mem, -1, sizeof mem);
auto dfs = [&](auto&& self, int i, int cnt, bool limit_low, bool limit_high, bool is_num) -> ll {
// 边界的返回值
if (i == n)
return is_num ? cnt : 0LL;
// 记忆化的状态
auto& v = mem[i][cnt][limit_low][limit_high][is_num];
if (v != -1)
return v;
ll res = 0;
// 前面填的都是 0
if (not is_num and low[i] == '0')
res += self(self, i + 1, 0, true, false, false);
// 第 i 个数位可以从 lo 枚举到 hi
int lo = limit_low ? low[i] - '0' : 0;
int hi = limit_high ? high[i] - '0' : 9;
int d0 = is_num ? 0 : 1;
for (int d = max(d0, lo); d <= hi; ++d) {
res += self(self, i + 1, cnt + (d == t), limit_low and (d == lo), limit_high and (d == hi), true);
}
return v = res;
};
return dfs(dfs, 0, 0, true, true, false);
}
void solve() {
ll a, b;
while (cin >> a >> b, a != 0 and b != 0) {
if (a > b)
swap(a, b);
vector<ll> ans;
for (int i = 0; i <= 9; i ++)
ans.push_back(cal(a, b, i));
for (auto x : ans)
cout << x << " ";
cout << "\n";
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}