Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <algorithm>
- #define LL long long int
- using namespace std;
- LL rec(LL l,LL c,int pas )
- {
- if(pas==1)
- return (l+c)%2;
- else
- {
- LL mid=1<<(pas-1);
- if(l<=mid&&c<=mid)
- return rec(l,c,pas-1);
- else
- if(l<=mid&&c>mid)
- return rec(l,(c-mid),pas-1)+mid;
- else
- if(l>mid&&c<=mid)
- return rec((l-mid ),c,pas-1)+mid;
- else
- return rec((l-mid),(c-mid),pas-1);
- }
- }
- int main()
- {
- freopen("tabela.in","r",stdin);
- freopen("tabela.out","w",stdout);
- LL a,b,dim,putere;
- dim=1;
- putere=0;
- scanf("%lld%lld",&a,&b);
- while(max(a,b)>=dim)
- dim*=2,++putere;
- printf("%lld",rec(a,b,putere));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement