Изменения рейтингов за последние раунды временно удалены. Скоро они будут возвращены. ×

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

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

There are 3 integers a, b, w.

There are 2 equations –

w+a=b

a (bitwise AND) b = 0;

I was given the value of w and he asked me to calculate the number of pairs (a, b) satisfying the two equations.

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

»
5 лет назад, # |
Rev. 4   Проголосовать: нравится 0 Проголосовать: не нравится

Let i be the left-most set bit in m (0 -based), then for ever a = "111111111..00000", where 1 appears aleast two times, and zero appears i times, then a&b = a&(a + w) = 0

Therefore the number of solutions is (for positive w).

»
5 лет назад, # |
Rev. 4   Проголосовать: нравится 0 Проголосовать: не нравится

I guess the first equation should look like a + b = w instead of a + w = b.

In case of a + b = w
In case of a + w = b