4fd800b3a8 2011-02-23 kinaba: //------------------------------------------------------------- 4fd800b3a8 2011-02-23 kinaba: // Next Combination 4fd800b3a8 2011-02-23 kinaba: // 4fd800b3a8 2011-02-23 kinaba: // Verified by 4fd800b3a8 2011-02-23 kinaba: // - SRM345 Div1 LV3 4fd800b3a8 2011-02-23 kinaba: //------------------------------------------------------------- 4fd800b3a8 2011-02-23 kinaba: 4fd800b3a8 2011-02-23 kinaba: LL next_combination(LL p) 4fd800b3a8 2011-02-23 kinaba: { 4fd800b3a8 2011-02-23 kinaba: assert( p > 0 ); 4fd800b3a8 2011-02-23 kinaba: LL lsb = p & -p; 4fd800b3a8 2011-02-23 kinaba: LL rem = p + lsb; 4fd800b3a8 2011-02-23 kinaba: LL rit = rem & ~p; 4fd800b3a8 2011-02-23 kinaba: return rem | (rit/lsb >> 1)-1; 4fd800b3a8 2011-02-23 kinaba: }