二叉树2 题解:
#include<bits/stdc++.h>
using namespace std;
void getNum(int m, int n, int &cnt){
if(m <= n){
cnt ++;
getNum(m * 2, n, cnt);
getNum(m * 2 + 1, n, cnt);
}
}
int main(){
int m, n;
while(cin >> m >> n){
int cnt = 0;
getNum(m, n, cnt);
cout << cnt << endl;
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发