文章

85

粉丝

0

获赞

426

访问

8.6k

头像
二叉树2 题解:
P1264 北京大学机试题
发布于2026年3月6日 11:28
阅读数 70

#include <bits/stdc++.h>

using namespace std;
int countnum=0;
int treavers(int m,int n) {;
    if(m>n) {
        return 0;
    }
    int left=treavers(2*m+1,n);
    int right=treavers(2*m,n);
    return left+right+1;
}

int main() {
    int m ,n;
    while(cin>>m>>n) {
        int ans=treavers(m,n);
        cout<<ans<<endl;
    }
}

 

登录查看完整内容


登录后发布评论

1 条评论
liux662
2026年3月9日 15:12

这个题目在acwing上用这个方法会超时欸,数据好像不是很强

赞(0)
回复给: