1106 Lowest Price in Supply Chain (25 分)(树的遍历)
求叶子结点处能活得最低价格以及能提供最低价格的叶子结点的个数
#include<bits/stdc++.h> using namespace std;
const int N=1e5+;
vector<int>vec[N];
int minn=0x3f3f3f3f;
int num=;
void dfs(int v,int step)
{
if(vec[v].size()==){
if(minn>step){
minn=step;
num=;
}
else if(minn==step){
num++;
} }
for(int i=;i<vec[v].size();i++){
dfs(vec[v][i],step+);
}
}
int main()
{
int n;
double price,rate;
scanf("%d %lf %lf",&n,&price,&rate);
for(int i=;i<n;i++){
int k;
scanf("%d",&k);
if(k!=){
for(int j=;j<k;j++){
int x;
scanf("%d",&x);
vec[i].push_back(x);
}
}
}
dfs(,);
printf("%.4f %d\n",price*1.0*pow(+rate/100.0,minn),num);
return ;
}
1106 Lowest Price in Supply Chain (25 分)(树的遍历)的更多相关文章
- 【PAT甲级】1106 Lowest Price in Supply Chain (25分)
题意:输入一个正整数N(<=1e5),两个小数P和R,分别表示树的结点个数和商品原价以及每下探一层会涨幅的百分比.输出叶子结点深度最小的商品价格和深度最小的叶子结点个数. trick: 测试点1 ...
- [建树(非二叉树)] 1106. Lowest Price in Supply Chain (25)
1106. Lowest Price in Supply Chain (25) A supply chain is a network of retailers(零售商), distributors( ...
- 1106. Lowest Price in Supply Chain (25)
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 ...
- PAT甲题题解-1106. Lowest Price in Supply Chain (25)-(dfs计算树的最小层数)
统计树的最小层数以及位于该层数上的叶子节点个数即可. 代码里建树我用了邻接链表的存储方式——链式前向星,不了解的可以参考,非常好用: http://www.cnblogs.com/chenxiwenr ...
- PAT甲级——1106 Lowest Price in Supply Chain(BFS)
本文同步发布在CSDN:https://blog.csdn.net/weixin_44385565/article/details/90444872 1106 Lowest Price in Supp ...
- 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 ...
随机推荐
- redis事务中的WATCH命令和基于CAS的乐观锁
转自:http://blog.sina.com.cn/s/blog_ae8441630101cgy3.html 在Redis的事务中,WATCH命令可用于提供CAS(check-and-set)功能. ...
- VisualSVN 4.0.10 破解版 附上破解过程
VisualSVN一般情况下使用不需要破解,可以直接使用社区授权.但是社区授权不支持域用户. 如果要再域下面使用就需要破解了. 原版的VisualSVN和破解后的DLL已打包上传(仅供学习使用) 破解 ...
- 精读《12 个评估 JS 库你需要关心的事》
1 引言 作者给出了从 12 个角度全面分析 JS 库的可用性,分别是: 特性. 稳定性. 性能. 包生态. 社区. 学习曲线. 文档. 工具. 发展历史. 团队. 兼容性. 趋势. 下面总结一下作者 ...
- 内置函数系列之 filter
filter 过滤 基本语法: s = filter(function,iterable) 将可迭代对象的每一个元素,传进函数中,根据函数中的判断条件,返回True或False 返回True的是保留的 ...
- 【Python3】操作文件,目录和路径
1.遍历文件夹和文件 Python代码 import os import os.path rootdir = "d:/test" for parent,dirnames,fi ...
- 硬盘安装Windows Server 2008(解决系统盘符变成D盘)
硬盘安装Windows 2008系统方法 操作系统最好用的无疑是server 2003,但是现在Server 2003支持的软件越来越少,很多是故意不支持Server 2003了, 像php5.5以上 ...
- 1016-06-首页20-封装工具条-有控件在viewDidLoad的时候距离顶部是0--到了viewWillAppear或viewDidAppear系统就加了64
- source insight插件
直使用sourceinsight编辑C/C++代码,sourceinsight是一个非常好用的编辑工具可以任意定位,跳转,回退,本人一直 使用该工具做C/C++开发,sourceinsight能够满足 ...
- C++ 基础 初始化列表
当一个类组合了其他类,或者使用了 const 成员,就要用 初始化列表. Class A {...}; Class B {...}; Class C { private: A a; B b; int ...
- Robots Gym - 101915G
传送门 The Robotics Olympiad teams were competing in a contest. There was a tree drawn on the floor, co ...