排列组合-CSDN博客

32 阅读1分钟
int getTwo(int end, int start) {
	int ret = 0;
	for (int i = end; i >= start; --i) {
		int x = i;
		while (x != 0)
			if ((x & 1) == 0) {
				ret++;
				x >>= 1;
			}
			else break;
	}
	return ret;
}

好像是获得start到end的各个数的2的程度

(n, m) = n * (n - 1) *(n - 2) * ... * (n - m + 1) /m!.