Advertisement
immuntasir

SUB2015-H

Feb 8th, 2015
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.80 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. int main()
  4. {
  5.     int T,cnt=1;
  6.     long long int mod =  1000000007;
  7.     scanf("%d",&T);
  8.     while (T--) {
  9.         long long int a,b;
  10.         scanf("%lld%lld",&a,&b);
  11.  
  12.         int i,k;
  13.         long long int sum = 0;
  14.  
  15.         long long int ara[20];
  16.  
  17.         for (k=a;k<=b;k++) {
  18.             long long int mul = 1;
  19.             int z =k;
  20.             int length = floor(log10(z)) +1;
  21.             for (i=0;i < length;i++) {
  22.                 if (z == 1) {
  23.                     break;
  24.                 }
  25.                 ara[i] = z % 10;
  26.                 z = z/10;
  27.                 mul = (mul * ara[i]) % mod ;
  28.             }
  29.             sum = (sum + mul) % mod  ;
  30.  
  31.         }
  32.         printf("Case %d: %lld\n",cnt, sum );
  33.         cnt++;
  34.  
  35.     }
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement