题解 | #排列与二进制#每一项都除够2,和相加
排列与二进制
https://www.nowcoder.com/practice/647fc23dc4e147328cc484e3aeb6cc2a
#include<cstdio> int main(){ int n, m; while (scanf("%d%d", &n, &m) != EOF){ if (n == 0 && m == 0){ break; } int ans = 0; for (int i = 0; i < m; i++){ int k = n - i; while (k % 2 == 0){ ans++; k= k / 2; } } printf("%d\n", ans); } }