Artifact 291928c8067379300b85ee18deb0a67853a450b4
- File
_lib/numeric/nextComb.cpp
- 2011-02-23 09:21:16 - part of checkin [4fd800b3a8] on branch trunk - Copied from private svn repository. (user: kinaba) [annotate]
- File
lib/numeric/nextComb.cpp
- 2011-02-23 11:18:09 - part of checkin [23dfcca431] on branch trunk - renamed _lib to lib (user: kinaba) [annotate]
//-------------------------------------------------------------
// Next Combination
//
// Verified by
// - SRM345 Div1 LV3
//-------------------------------------------------------------
LL next_combination(LL p)
{
assert( p > 0 );
LL lsb = p & -p;
LL rem = p + lsb;
LL rit = rem & ~p;
return rem | (rit/lsb >> 1)-1;
}