Advertisement
hasib_mo

Untitled

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