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 ...
随机推荐
- CentOS下用rinetd做端口转发
windows下的端口转发一般用的是自带的nat和porttunnel.portmap linux下端口转发映射的程序叫rinetd,启动方法rinetd -c /etc/rinetd.conf , ...
- Next K Permutation
3457: Next K Permutation 时间限制: 1 Sec 内存限制: 128 MB提交: 4 解决: 4[提交] [状态] [讨论版] [命题人:admin] 题目描述 n 个数有 ...
- 关于 npm install 命令
使用 `npm install` 命令安装模块时 ,有以下几种形式: 安装模块到项目 node_modules 目录下,不会将模块依赖写入 dependencies 或 devDependencies ...
- CSS 滤镜技巧与细节
本文主要介绍 CSS 滤镜的不常用用法,希望能给读者带来一些干货! 注意:ie不兼容 本文所描述的滤镜,指的是 CSS3 出来后的滤镜,不是 IE 系列时代的滤镜,话不多说,直接开车,语法如下: { ...
- python模块之正则
re模块 可以读懂你写的正则表达式 根据你写的表达式去执行任务 用re去操作正则 正则表达式 使用一些规则来检测一些字符串是否符合个人要求,从一段字符串中找到符合要求的内容.在线测试网站:http:/ ...
- 分布式系统session一致性问题
一.引言 1.什么是session Session 是服务器用来保存用户操作的一系列会话信息,由Web容器进行管理.最常见的,会把用户的登录信息.用户信息存储在 session 中,以保持登录状态. ...
- Open closed principle
#include <iostream> using namespace std; class Book { public: string getContents() { return &q ...
- GNU 汇编 协处理器指令
1. CP15 协处理器 16组寄存器 mcr 写 mrc (rgeister CP15) 读 CP15 到 Register mrc p15,0,c0,c0,0
- LInux操作随手笔记
一.find 的用法 实例 find / -name test.txt 就可以找到这个文件的路径(如果存在). 二.学用vi编辑器,学用rz往linux服务器上面上传文件 linux中rz 和 sz ...
- windows下的node.js和npm的安装步骤详解
一.使用之前,我们先来掌握3个东西是用来干什么的. npm: Nodejs下的包管理器. webpack: 它主要的用途是通过CommonJS的语法把所有浏览器端需要发布的静态资源做相应的准备,比如资 ...