题解 | #二叉树#
二叉树
http://www.nowcoder.com/practice/f74c7506538b44399f2849eba2f050b5
#include <iostream>
using namespace std;
int CountNodes(int m, int n) {
if (m > n) {
return 0;
}
else {
return CountNodes(2 * m, n) + CountNodes(2 * m + 1, n) + 1;
}
}
int main()
{
int m, n;
while (cin >> m >> n) {
if (m == 0 && n == 0) {
break;
}
cout << CountNodes(m, n) << endl;
}
return 0;
}