首页
DreamJudge
院校信息
专业题库
模拟考试
机试真题
上岸课程
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
路西法
2025年3月24日 15:02
哈夫曼树 题解:
P1382
回复 0
|
赞 1
|
浏览 83
注意是多组数据哈,否则通过率就是60% #include<stdio.h> #include<queue> using namespace std; int main(){ int n; while(scanf("%d",&n)!=EOF){ priority_queue<int> myQueue; for(int...
carrot_huan
2025年3月12日 14:06
哈夫曼树 题解:哈夫曼树的值等于所有非叶结点值的和+小根堆实现
P1382
回复 0
|
赞 16
|
浏览 242
#include<iostream> #include<queue> using namespace std; int main() { int n; while (cin >> n) { priority_queue<int, vector<int>, greater<int>> pq; &nbs...
西电机试专家
2025年2月27日 11:36
哈夫曼树 题解:求WPL的两种方法,图片详解
P1382
回复 0
|
赞 28
|
浏览 404
#include<bits/stdc++.h> using namespace std; //求WPL,换一种求法 int main(){ int n; //priority_queue<int,vector<int>,greater<int>>pq;(定义在这里只有60%通过率) while(cin>>n) { &...
有道
2024年5月22日 21:16
哈夫曼树 题解:优先队列——排坑
P1382
回复 0
|
赞 28
|
浏览 978
使用优先队列 啊啊啊啊,服辣!!题目说输入多组数据。。。所以要在最外面while(cin>>n) de了好久 Orzzz #include<bits/stdc++.h> using namespace std; int main() { int n; while(cin>>n) { priority_queue<int,vector<int>,greater<int>>q; int res=0; //入队 while(n--) { ...
为欢几何
2024年4月8日 10:39
哈夫曼树 题解:最简单易懂的思路,AC
P1382
回复 2
|
赞 29
|
浏览 1.8k
//哈夫曼树,输出所有结点的值与权值的乘积之和 #include<bits/stdc++.h> using namespace std; int main() { int n; while(cin >> n) { int num[1005]; for(int i = 0; i < n; i++) cin >> num[i]; sort(num, num + n); int sum = 0; for(in...
Cookie‘s AE86
2024年3月24日 14:34
哈夫曼树 题解:c++ priority_queue实现
P1382
回复 0
|
赞 4
|
浏览 808
#include<bits/stdc++.h> using namespace std; int main() { int n; while(cin >> n){ int sum = 0; int tmp = 0; priority_queue<int, vector<int>, greater<i...
孙某人
2024年2月24日 10:33
哈夫曼树 题解:新手简单易懂
P1382
回复 1
|
赞 8
|
浏览 1.2k
#include <iostream> using namespace std; int min(int a[],int n){ int nn=0; long long int minn=999999999; for(int i=0;i<n;i++){ if(a[i]==-1) continue; else if(a[i]<minn) minn=a[i]; } //cout << minn <<endl; return minn; } int mini(int a[],int n){ in...
阿离
2024年3月13日 17:09
哈夫曼树 题解:最小栈做法
P1382
回复 0
|
赞 1
|
浏览 783
#include <bits/stdc++.h> using namespace std; int main() { int n, x; while(cin>>n){ priority_queue<int, vector<int>, greater<int>> q; // 定义存储整数的最小堆 for (int i = 0; i < n; i++) { &n...
小王桐学
2024年2月14日 20:40
哈夫曼树 题解:C题解简单思路
P1382
回复 2
|
赞 12
|
浏览 1.2k
先排序,最小的两个数在前面,weight权值为非叶子节点值的总和 #include <stdio.h> void Sort(int a[],int n) { int i,j,t; for(i = 0; i < n-1; i++) for(j = 1; j < n-i; j++) if(a[j] < a[j-1]) { t = a[j]; a[j] = a[j-1]; a[j-1] = t; } } int main() { int t,i,n,a[...
DestinyCares+++
2024年2月23日 15:37
哈夫曼树 题解:直接优先队列
P1382
回复 0
|
赞 4
|
浏览 1.2k
#include<iostream> #include<string> #include<queue> using namespace std; int main(){ int n; while (cin>>n) { priority_queue<int,vector<int>,greater<int>> q; ...
1
2
题目
哈夫曼树
题解数量
19
发布题解
在线答疑
热门题解
1
哈夫曼树 题解:最简单易懂的思路,AC
2
哈夫曼树 题解:优先队列——排坑
3
哈夫曼树 题解:求WPL的两种方法,图片详解
4
哈夫曼树 题解:哈夫曼树的值等于所有非叶结点值的和+小根堆实现
5
哈夫曼树 题解:C题解简单思路
6
哈夫曼树 题解:新手简单易懂
7
1382 哈弗曼树 树的带权路径+优先级队列两种方法
8
哈夫曼树 题解:c++ priority_queue实现
9
哈夫曼树 题解:直接优先队列
10
哈夫曼树 题解:优先队列 + 迭代求带权路径和