Artifact Content
Not logged in

Artifact 291928c8067379300b85ee18deb0a67853a450b4


//-------------------------------------------------------------
// 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;
}