Bellala's blog

By Bellala, history, 3 years ago, In English

Some properties of bitwise operations seem very classical, but I had no idea of them until the first time I met them. Here are some examples: (^ is for bitwose XOR)

a+b = a&b + a|b

if a^b^c = 0, then (a-k)^(b-k)^(c-k)!=0 forall 0<k<=min(a,b,c)

a^b >= a-b (got it from uva12716 GCD XOR)

a+b = (a^b) + 2(a&b) (1451E1 - Bitwise Queries (Easy Version))

There are countless blogs discussing the most basic properties like "a=b^c and b=a^c implies c=a^b", or tricks like "enumerate subsets with bitwise operations" and "swap two values without a third variable". But I didn't find what I need.

Can you give me a list of these special properties of bitwise operations? Or tell me that there's no need to know about them, everyone just derive them through the basic ones in a contest.

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

»
3 years ago, # |
  Vote: I like it +8 Vote: I do not like it

This blog might interest you

»
3 years ago, # |
  Vote: I like it +24 Vote: I do not like it

Yeah this kind of property is supposed to be thought in contest. All of those properties you listed are very intuitive on the reason why they work and their use cases are very fringe, so it doesnt make much sense to study them beforehand.

Imo it's much more important that you understand the reason why those formulas work (as it will help you get how to think on this sort of problem) than getting a list that will have a lot of formulas but they might not appear ever again in rounds.

If you really want you can check problems with the "bitmasks" tag tho