Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<math.h>
- int main ()
- {
- long long y,x,c,k;
- int n,i;
- scanf("%d", &n);
- for(i=1;i<=n;i++)
- {
- c=0;
- scanf("%lld %lld", &x, &y);
- if(x%3==0)
- {
- x=x+1;
- c++;
- }
- else if(x%3==2)
- {
- x=x+2;
- c=c+2;
- }
- else
- {
- x=x;
- }
- if(y%3==1)
- {
- y=y-1;
- }
- else if(y%3==2)
- {
- y=y-2;
- c=c+1;
- }
- else
- {
- y=y;
- }
- k=((y-x+1)*2)/3;
- c=c+k;
- printf("Case %d: %lld\n",i ,c);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement