记忆化搜索解数位dp方便快捷见效快。。。。
const int MAX_DIGITS, MAX_STATUS;
LL f[MAX_DIGITS][MAX_STATUS], bits[MAX_DIGITS];
LL dfs(int position, int status, bool limit, bool first)
{
if (position == -1)
return s == target_status;
if (!limit && !first && ~f[position][status])
return f[position][status];
int u = limit ? bits[position] : MAX_BITS;
LL ret = 0;
for (int i = 0; i <= u; i++)
{
ret += dfs(position - 1, next_status(status, i), limit && i == u, first && !i);
}
return limit || first ? ret : f[pos][status] = ret;
}
LL calc(LL n)
{
CLR(f, -1);
int len = 0;
while (n)
{
bits[len++] = n % 10;
n /= 10;
}
return dfs(len - 1, 0, true, true);
}
int main()
{
//freopen("0.txt", "r", stdin);
LL a, b;
while (cin >> a >> b)
cout << calc(b) - calc(a - 1) << endl;
return 0;
}