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