-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuva11038.cpp
More file actions
35 lines (32 loc) · 750 Bytes
/
uva11038.cpp
File metadata and controls
35 lines (32 loc) · 750 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <cstdio>
#include <cstring>
#include <cmath>
long long cal(long long n) {
if (n == -1) return -1;
int cnt = 0;
int digit[12] = {0};
long long nn = n;
while (nn > 0) {
digit[cnt++] = nn % 10LL;
nn /= 10LL;
}
long long ans = 0;
long long pre = 0, tail = 0;
for (int i = 0; i < cnt; ++i) {
pre = n / (long long)pow(10., i + 1);
if (digit[i] == 0) ans += (pre - 1) * (long long) pow(10., 1. * i) + (tail + 1);
else ans += pre * (long long) pow(10., 1. * i);
tail = tail + digit[i] * (long long) pow(10., 1. * i);
}
return ans;
}
int main() {
long long m, n;
while (2 == scanf("%lld%lld", &m, &n)) {
if (-1 == m && -1 == n)
break;
long long ans = cal(n) - cal(m - 1);
printf("%lld\n", ans);
}
return 0;
}