2022.7.21 AcWing LeetCode
乘法原理
每个小数后面相乘的0,在结果的积中是不变的。
#include <bits/stdc++.h>
using namespace std;
int n, m;
int ans;
int main() {
while (scanf("%d %d", &n, &m)) {
ans = 0;
if (n == 0 || m == 0)
break;
for (int i = n; i >= n - m + 1; i--) {
int t = i;
while (t % 2 == 0) {
t /= 2;
ans++;
}
}
printf("%d\n", ans);
}
return 0;
}
LeetCode题解:
https://leetcode.cn/problems/binary-tree-pruning/solution/dfs-by-sen-xm-ezue/