XORIT - Editorial

i guess this is what you wanted to understand.
We can see that in range [1,R] there will be half even (maybe one less) and appx. half odd (maybe one more) numbers. So our focus here is only even numbers. We take all numbers and divide each of them by 2. This way we eliminated odd numbers. (example : 4 and 5 both when divided by 2 give 2, which multiplied by 2 gives 4.) However, as we have divided the original number by two (in binary, making …10 as …1), we have to multiply the lowest bit of each number by 2, or to our advantage, multiplying the new answer by 2.

Because a and B must not share any common bits

Okay, I looped from L to R and used ffs() function to calculate the position of rightmost set bit. Why is this TLE?

As R-L<=10^9 IN WORST CASE IT MAY BE EQUAL TO 10^9 TOTAL TEST CASES 10^5, SO OVERALL TIME COMPLEXITY OF YOUR CODE IS EQUAL TO 10^14 WHICH IS UNACHEIVABLE IN 1s it will take
10^14/10^8=10^6 seconds approx your code will print output almost in 100 days.

thank you so much.

1 Like

Happy to help :hearts:

Did anyone try MO + sqrt decomposition ?

well explained brother. thank you.

Thanksss a lottt

Hi @kmaaszraa , explanation is great. I just did not understand the syntax of Get function, could you help me out in understanding this.

Thanks