题解 | 二叉树:递归求解
二叉树
https://www.nowcoder.com/practice/f74c7506538b44399f2849eba2f050b5
#include <iostream>
using namespace std;
int sum(int m, int n)
{
if(m==n)
{
return 1;
}
else if(m>n)
{
return 0;
}
else{
return sum(2*m,n)+sum(2*m+1,n)+1;
}
}
int main() {
int m,n;
while (cin >> m >> n) {
cout << sum(m,n) << endl;
}
}
#考研复试机试上机个人解析##考研#
字节跳动公司福利 1356人发布