Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.68 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<math.h>
  3. int main ()
  4. {
  5.     long long y,x,c,k;
  6.     int n,i;
  7.     scanf("%d", &n);
  8.     for(i=1;i<=n;i++)
  9.     {
  10.         c=0;
  11.        scanf("%lld %lld", &x, &y);
  12.        if(x%3==0)
  13.        {
  14.            x=x+1;
  15.            c++;
  16.        }
  17.        else if(x%3==2)
  18.        {
  19.            x=x+2;
  20.            c=c+2;
  21.        }
  22.        else
  23.        {
  24.            x=x;
  25.        }
  26.        if(y%3==1)
  27.        {
  28.            y=y-1;
  29.        }
  30.        else if(y%3==2)
  31.        {
  32.            y=y-2;
  33.            c=c+1;
  34.        }
  35.        else
  36.        {
  37.            y=y;
  38.        }
  39.        k=((y-x+1)*2)/3;
  40.        c=c+k;
  41.        printf("Case %d: %lld\n",i ,c);
  42.     }
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement