You are given two integers l and r in double portrayal. Let g(x,y) be equivalent to the bitwise XOR of all integers from x to y comprehensive (that is x⊕(x+1)⊕⋯⊕(y−1)⊕y). How about we characterize f(l,r) as the limit of all upsides of g(x,y) fulfilling l≤x≤y≤r. Output f(l,r).
Correct answer will be upvoted else downvoted. Computer science.
You are given two integers l and r in double portrayal. Let g(x,y) be equivalent to the bitwise XOR of all integers from x to y comprehensive (that is x⊕(x+1)⊕⋯⊕(y−1)⊕y). How about we characterize f(l,r) as the limit of all upsides of g(x,y) fulfilling l≤x≤y≤r.
Output f(l,r).
Input
The primary line contains a solitary integer n (1≤n≤106) — the length of the paired portrayal of r.
The subsequent line contains the double portrayal of l — a line of length n comprising of digits 0 and 1 (0≤l<2n).
The third line contains the paired portrayal of r — a line of length n comprising of digits 0 and 1 (0≤r<2n).
It is ensured that l≤r. The paired portrayal of r doesn't contain any additional driving zeros (if r=0, its parallel portrayal comprises of a solitary zero). The paired portrayal of l is gone before with driving zeros so its length is equivalent to n.
Output
In a solitary line output the worth of f(l,r) for the given pair of l and r in twofold portrayal without additional driving zeros.
Step by step
Solved in 4 steps with 1 images