Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <cmath>
- long long int calcZero(long long int n) {
- long long int mul=1, rem=0,zeros=0,len;
- len = (int)log10(n);
- while (n!=0) {
- n = n/10;
- zeros += n*mul;
- mul *= 10;
- }
- mul=1;
- for (int i=1; i<len;i++) {
- zeros = zeros - mul*9;
- mul *=10;
- }
- zeros++;
- return zeros;
- }
- int main() {
- long long int n1, n2;
- while (scanf("%lld %lld", &n1, &n2) == 2) {
- if (n1<0 && n1 <0) break;
- if (n1==0) printf("1\n");
- else printf("%lld\n", calcZero(n2) - calcZero(n1-1));
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment