Differences From Artifact [80d6730d2c161aa4]:
- File
_lib/typical/bitop.cpp
- 2011-02-23 09:21:16 - part of checkin [4fd800b3a8] on branch trunk - Copied from private svn repository. (user: kinaba) [annotate]
- File
lib/typical/bitop.cpp
- 2011-02-23 11:18:09 - part of checkin [23dfcca431] on branch trunk - renamed _lib to lib (user: kinaba) [annotate]
To Artifact [f82714ac139d7457]:
- File
lib/typical/bitop.cpp
- 2013-06-27 00:12:26 - part of checkin [8f8efc5938] on branch trunk - subset iteration. (user: kinaba) [annotate]
1 1 int bitcnt(LL x)
2 2 {
3 3 int c = 0;
4 4 for(; x; x>>=1)
5 5 c += x&1;
6 6 return c;
7 7 }
8 +
9 +
10 +/* for every nonempty subset of S : O(2^|S|)
11 + for(int sub=S; sub; sub=(sub-1)&S) { ... }
12 +
13 +*/