文章

37

粉丝

67

获赞

3

访问

8.9k

头像
二叉树2 题解:简简单单的递归来了
P1264 北京大学机试题
发布于2024年3月8日 15:45
阅读数 256

#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

int cnt = 0;
int m, n;
void searchRoute(int x) {
    if (x > n) {
        return;
    }
    else {
        cnt++;
        searchRoute(2 * x);
        searchRoute(2 * x + 1);
    }
    
}

int main()
{
    while (cin >> m>> n) {
        //为a填值
        if (m > n) {
            cout << 0 << endl;
        }
        else {
            searchRoute(m);
            cout << cnt ...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发