1106 Lowest Price in Supply Chain
题意:略
思路:寻找树的叶结点中深度最低的,记录最低深度minDepth和具有相同最低深度的结点个数cnt。
代码:
#include <cstdio> #include <cmath> #include <vector> using namespace std; ; vector<int> tree[maxn]; ,cnt=; void dfs(int v,int depth) { ){ if(depth<minDepth){ cnt=; minDepth=depth; }else if(depth==minDepth){ cnt++; } } for(auto u:tree[v]) dfs(u,depth+); } int main() { int n,k; double price,r; scanf("%d%lf%lf",&n,&price,&r); ;i<n;i++){ scanf("%d",&k); int kid; ;j<k;j++){ scanf("%d",&kid); tree[i].push_back(kid); } } dfs(,); r=(r+)/100.0; printf("%.4f %d",price*pow(r,minDepth),cnt); ; }
1106 Lowest Price in Supply Chain的更多相关文章
- [建树(非二叉树)] 1106. Lowest Price in Supply Chain (25)
1106. Lowest Price in Supply Chain (25) A supply chain is a network of retailers(零售商), distributors( ...
- PAT甲级——1106 Lowest Price in Supply Chain(BFS)
本文同步发布在CSDN:https://blog.csdn.net/weixin_44385565/article/details/90444872 1106 Lowest Price in Supp ...
- 1106. Lowest Price in Supply Chain (25)
A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone invo ...
- PAT 甲级 1106 Lowest Price in Supply Chain
https://pintia.cn/problem-sets/994805342720868352/problems/994805362341822464 A supply chain is a ne ...
- PAT 1106 Lowest Price in Supply Chain
A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone invo ...
- PAT Advanced 1106 Lowest Price in Supply Chain (25) [DFS,BFS,树的遍历]
题目 A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)– everyone in ...
- PAT (Advanced Level) 1106. Lowest Price in Supply Chain (25)
简单dfs #include<cstdio> #include<cstring> #include<cmath> #include<vector> #i ...
- 1106 Lowest Price in Supply Chain (25 分)(树的遍历)
求叶子结点处能活得最低价格以及能提供最低价格的叶子结点的个数 #include<bits/stdc++.h> using namespace std; ; vector<int> ...
- PAT甲题题解-1106. Lowest Price in Supply Chain (25)-(dfs计算树的最小层数)
统计树的最小层数以及位于该层数上的叶子节点个数即可. 代码里建树我用了邻接链表的存储方式——链式前向星,不了解的可以参考,非常好用: http://www.cnblogs.com/chenxiwenr ...
随机推荐
- LeetCode OJ:Number of Islands(孤岛计数)
Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surro ...
- final方法,abstract方法和abstract类,native方法
final方法 1.为了确保某个函数的行为在继承过程中保持不变,并且不能被覆盖(override),可以使用final方法. 2.为了效率上的考虑,将方法声明为final,让编译器对此方法的调用进行优 ...
- HBase架构解析
Hbase组件  客户端Client 整个HBase集群的入口 使用HBase RPC机制与HMaster和HRegionserver通信 与HMaster通信进行管理类的操作 与HRegionse ...
- Vim技能修炼教程(12) - Vim的脚本语言支持
Vim的脚本语言支持 本节开始,我们正式接触vimscript这门古老的脚本语言. 首先要说明,vim支持的扩展语言很多,比如python, python3, ruby, lua,tcl等常见脚本语言 ...
- Vim技能修炼教程(6) - 行编辑器
在很久很久以前,计算机的运算能力还很弱,终端与主机的通信也不好.在没有显示器的时代,只能通过电传打字机跟主机通信.那时候只有行编辑器,编辑的时候只能在一行中进行.需要显示哪一行,就把哪一行或者哪几行打 ...
- word-break:break-all 打散文字,强制对齐
- librec库
固定初始化矩阵值 net.librec.math.structure -> class DenseMatrix -> void init()
- EM算法定义及推导
EM算法是一种迭代算法,传说中的上帝算法,俗人可望不可及.用以含有隐变量的概率模型参数的极大似然估计,或极大后验概率估计 EM算法定义 输入:观测变量数据X,隐变量数据Z,联合分布\(P(X,Z|\t ...
- 51nod 1600 Simple KMP【后缀自动机+LCT】【思维好题】*
Description 对于一个字符串|S|,我们定义fail[i],表示最大的x使得S[1..x]=S[i-x+1..i],满足(x<i) 显然对于一个字符串,如果我们将每个0<=i&l ...
- xml的读取(曾删改)
获取XML 得到 需要查询的字段名 private string GetXml(string TableName) { try { string TbName = TableName.Split('_ ...