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

Автор thebigjuicyd, история, 4 года назад, По-английски

I just participated in the Div 2 Algo Muse Comp and on question 3, you could use &=. But the &= was not used with booleans. It was used with int, like a &= n — 1; What does the &= mean and do in this int context?

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

»
4 года назад, # |
  Проголосовать: нравится +18 Проголосовать: не нравится

a &= n-1 is same as a = a & (n-1) it is called bit-wise and.

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

Google and read about bitwise operators.