题解 | #二叉树#
二叉树
http://www.nowcoder.com/questionTerminal/f74c7506538b44399f2849eba2f050b5
递归求解,代码简单,但理解不易
#include <iostream>
using namespace std;
int n;
int find(int m){
if(m>n) return 0;
return 1+find(2*m)+find(2*m+1);
}
int main(){
int m;
while(cin>>m>>n){
cout<<find(m)<<endl;
}
}