Ewwa's blog

By Ewwa, history, 7 years ago, In English

Hello ! Can somebody explain to me how to solve this problem in O(logn) ?

Given N ( N <= 10^18 ) find the number of ordered pairs (a, b) for which a ^ b = X. ( 1 <= a, b <= N )

X is the first number >= N which has all it's bits equal to 1. For example if N = 5(101) then X = 7(111) and if N = 7 then X = 7.

Additional challenge : X is any number between 1 and 10^18, independent of N.

Problem link if somebody wants to submit : https://www.hackerearth.com/problem/algorithm/roy-and-maximum-xor/

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By Ewwa, history, 7 years ago, In English

I followed this post http://codeforces.com/blog/entry/18051 to learn segment tree and I really like the implementation, but can't figure out how to implement fractional cascading. Any idea ?

Full text and comments »

  • Vote: I like it
  • +5
  • Vote: I do not like it