题解 | #二叉树#
二叉树
https://www.nowcoder.com/practice/f74c7506538b44399f2849eba2f050b5
#include <iostream>
using namespace std;
int tree(int m, int n){
if (m > n) return 0;
else{return 1 + tree(2*m,n) + tree(2*m+1,n);}}
int main() {
int m, n;
while (scanf("%d%d",&m,&n)!=EOF) { // 注意 while 处理多个 case
if(m == n) break;
printf("%d",tree(m,n));}}
// 64 位输出请用 printf("%lld")
查看1道真题和解析