Advertisement
a53

Tableta

a53
Feb 2nd, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #include <cstdio>
  2. #include <algorithm>
  3. #define LL long long int
  4. using namespace std;
  5.  
  6. LL rec(LL l,LL c,int pas )
  7. {
  8. if(pas==1)
  9. return (l+c)%2;
  10. else
  11. {
  12. LL mid=1<<(pas-1);
  13. if(l<=mid&&c<=mid)
  14. return rec(l,c,pas-1);
  15. else
  16. if(l<=mid&&c>mid)
  17. return rec(l,(c-mid),pas-1)+mid;
  18. else
  19. if(l>mid&&c<=mid)
  20. return rec((l-mid ),c,pas-1)+mid;
  21. else
  22. return rec((l-mid),(c-mid),pas-1);
  23. }
  24. }
  25.  
  26. int main()
  27. {
  28. freopen("tabela.in","r",stdin);
  29. freopen("tabela.out","w",stdout);
  30. LL a,b,dim,putere;
  31. dim=1;
  32. putere=0;
  33. scanf("%lld%lld",&a,&b);
  34. while(max(a,b)>=dim)
  35. dim*=2,++putere;
  36. printf("%lld",rec(a,b,putere));
  37. return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement