### SirRembocodina's blog

By SirRembocodina, history, 10 months ago, translation,

In this thread it is shown how to go though all the submasks of a given mask without extra space or time. I needed to do the same thing for the overmasks, but I did not find anything. Based on the formula mask ^ (~mask) = -1, my brother gave me this code:

    for (int over = (1 << n) - 1; over > 0; over = ((over - mask - 1) & ~mask) + mask) {
cout << over << " ";
}


It really works. But can I simplify it, so it could be easier remembered during the contest?

• +28

 » 10 months ago, # |   +94 for (int mask = need; mask < (1 << n); mask = (mask + 1) | need) { } 
•  » » 10 months ago, # ^ |   +15 Genial, thank you.
 » 10 months ago, # |   +80
 » 10 months ago, # |   +11 you want the overmasks of $S$ (i.e.: the masks of which $S$ is submask). I think it's the same as the NOT ($\text{~}$) of submasks of $\text{~} S$. Correct me if I'm wrong.
 » 5 weeks ago, # |   +39 This post has no comment newer than 8 months ago. How did it appear under "Recent actions"?
•  » » 5 weeks ago, # ^ |   +12 Probably someone posted a comment and deleted it.
•  » » » 5 weeks ago, # ^ |   +11 Or OP made an edit.