Advertisement
hasib_mo

divisible by 3(accepted)

Mar 11th, 2012
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.39 KB | None | 0 0
  1. #include<stdio.h>
  2. int found(int a)
  3. {
  4. int res=a/3;
  5. res=res*2;
  6.  
  7.    if(a%3==2)
  8.         {
  9.             return res+1;
  10.  
  11.         }
  12.     else
  13.         {
  14.             return res;
  15.         }
  16. }
  17.  
  18.  
  19. int main(void)
  20. {
  21.  
  22.  
  23. int a,b,cases,caseno=0;
  24. scanf("%d",&cases);
  25. while(cases--)
  26. {
  27. scanf("%d %d",&a,&b);
  28.  
  29.  printf("Case %d: %d\n",++caseno,found(b)-found(a-1));
  30. }
  31. return 0;
  32.  
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement