immuntasir

UVA 11038

Mar 20th, 2015
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.61 KB | None | 0 0
  1. #include <cstdio>
  2. #include <cmath>
  3. long long int calcZero(long long int n) {
  4.     long long int mul=1, rem=0,zeros=0,len;
  5.     len = (int)log10(n);
  6.     while (n!=0) {
  7.         n = n/10;
  8.         zeros += n*mul;
  9.         mul *= 10;
  10.     }
  11.     mul=1;
  12.     for (int i=1; i<len;i++) {
  13.         zeros = zeros - mul*9;
  14.         mul *=10;
  15.     }
  16.     zeros++;
  17.     return zeros;
  18. }
  19. int main() {
  20.     long long int n1, n2;
  21.     while (scanf("%lld %lld", &n1, &n2) == 2) {
  22.         if (n1<0 &&  n1 <0) break;
  23.         if (n1==0) printf("1\n");
  24.         else printf("%lld\n", calcZero(n2) - calcZero(n1-1));
  25.     }
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment