Please, try EDU on Codeforces! New educational section with videos, subtitles, texts, and problems. ×

thebigjuicyd's blog

By thebigjuicyd, history, 4 weeks ago, In English,

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?

 
 
 
 
  • Vote: I like it
  • -11
  • Vote: I do not like it

»
4 weeks ago, # |
  Vote: I like it +18 Vote: I do not like it

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

»
4 weeks ago, # |
  Vote: I like it +4 Vote: I do not like it

Google and read about bitwise operators.