Submission
Status:
PPPPPPPPPP
Score: 100
User: admin
Problemset: J.Nine Khanaphat
Language: cpp
Time: 0.003 second
Submitted On: 2024-10-13 22:55:41
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll C[50];
ll count(ll x) {
// printf("%lld\n", x);
if (x < 9) return 0;
if (x == 9) return 1;
ll e = x;
ll r = 0;
while (e>0) {
e/=10;r++;
}
ll div = x/C[r-1];
ll mod = x%C[r-1];
return div * (r-1)*C[r-2] + (div ==9 ? mod+1 : 0) + count(mod);
}
ll A, B;
int main() {
C[0]=1;
for (int i=1; i<=16; i++) C[i] = 10*C[i-1];
scanf("%lld %lld", &A, &B);
printf("%lld", count(B) - count(A-1));
}