首页
DreamJudge
院校信息
考研初试
考研复试
保研专区
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
书岁痕
2026年3月14日 16:38
二叉树2 题解:
P1264
回复 0
|
赞 2
|
浏览 37
简单递归 #include<iostream> using namespace std; int count; void child(int x,int y){ if(x>y) return ; count++; child(x*2,y); child(x*2+1,y); } int main(){ int m,n; ...
5653565
2026年3月11日 11:38
二叉树2 题解:
P1264
回复 0
|
赞 2
|
浏览 83
递归,边界条件:1.当前权值大于n,不满足条件,返回0 2.当前权重小于等于n,则左右递归计算子树满足条件的结点数求和,再+1(当前结点权值满足<=n条件) #include <iostream> using namespace std; int count(int a,int n) { if(a>n) {return 0;} else {return count(2*a,n)+count(2*a+1,n)+1;} } int main() { int m,n; while(cin>>m&g...
uly
2026年3月6日 11:28
二叉树2 题解:
P1264
回复 1
|
赞 2
|
浏览 66
#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&...
bro
2026年2月26日 19:50
二叉树2 题解:c++,不递归,用层序遍历的队列思想也行
P1264
回复 1
|
赞 8
|
浏览 185
#include <bits/stdc++.h> using namespace std; int main(){ int m,n; while(cin >> m >> n){ queue<int> q; int sum = 0; q.push(m); &nb...
Sponge_Bob
2026年2月22日 00:08
二叉树2 题解:11行快速解决
P1264
回复 0
|
赞 1
|
浏览 107
#include<bits/stdc++.h> using namespace std; int find(int n,int T){ if(T>n) return 0; return find(n,2*T)+find(n,2*T+1)+1; } int main(){ int m,n; while(cin>>m>>n) cout< return 0...
cczz
2025年8月13日 18:17
二叉树2 题解:
P1264
回复 0
|
赞 5
|
浏览 571
#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); c...
2794828275
2025年3月13日 18:12
二叉树2 题解:简单递归,5行结束
P1264
回复 1
|
赞 14
|
浏览 1.4k
#include<iostream> using namespace std; int nod(int m, int n) { if (m > n) { return 0; } if (m > n / 2) { return 1; } &n...
Theeastisred
2025年3月19日 22:18
二叉树2 题解:完全二叉树孩子结点公式的运用
P1264
回复 0
|
赞 4
|
浏览 848
#include<bits/stdc++.h> using namespace std; int solve(int m,int n){ if(m==n) return 1; else if(m>n) return 0; else return 1+solve(m*2,n)+solve(m*2+1,n); } int main(){ int m,n; while(c...
zxjrheaven
2025年3月17日 21:12
二叉树2 题解:暴力
P1264
回复 0
|
赞 0
|
浏览 1.0k
#include <bits/stdc++.h> using namespace std; int jisuan(int m,int n) { if(m>n)return 0; else { return jisuan(2*m,n)+jisuan(2*m+1,n)+1; } } int main() {  ...
西电机试专家
2025年3月2日 09:06
二叉树2 题解:修改先序遍历
P1264
回复 0
|
赞 22
|
浏览 1.9k
//还有不到一个月复试,大家一定要上岸啊 #include<bits/stdc++.h> using namespace std; int cnt=0;//(count 是标准库中的一个函数名) //递归三要素:递归终止条件,递归式,递归返回结果 void result(int i,int n) { if(i<=n){ cnt++; result(2*...
1
2
3
题目
二叉树2
题解数量
25
发布题解
在线答疑
热门题解
1
二叉树2 题解:修改先序遍历
2
二叉树2 题解:简单递归,5行结束
3
二叉树2 题解:c++,不递归,用层序遍历的队列思想也行
4
二叉树2 题解:递归C++
5
二叉树2 题解:
6
二叉树2 题解:
7
二叉树2 题解:
8
利用 2*i 和 2*i+1 的极简代码
9
二叉树2 题解:完全二叉树孩子结点公式的运用
10
蒟蒻作法