Блог пользователя Ewwa

Автор Ewwa, история, 7 лет назад, По-английски

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/

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор Ewwa, история, 7 лет назад, По-английски

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 ?

Полный текст и комментарии »

  • Проголосовать: нравится
  • +5
  • Проголосовать: не нравится