求叶子结点处能活得最低价格以及能提供最低价格的叶子结点的个数

#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 分)(树的遍历)的更多相关文章

  1. 【PAT甲级】1106 Lowest Price in Supply Chain (25分)

    题意:输入一个正整数N(<=1e5),两个小数P和R,分别表示树的结点个数和商品原价以及每下探一层会涨幅的百分比.输出叶子结点深度最小的商品价格和深度最小的叶子结点个数. trick: 测试点1 ...

  2. [建树(非二叉树)] 1106. Lowest Price in Supply Chain (25)

    1106. Lowest Price in Supply Chain (25) A supply chain is a network of retailers(零售商), distributors( ...

  3. 1106. Lowest Price in Supply Chain (25)

    A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone invo ...

  4. PAT Advanced 1106 Lowest Price in Supply Chain (25) [DFS,BFS,树的遍历]

    题目 A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)– everyone in ...

  5. PAT (Advanced Level) 1106. Lowest Price in Supply Chain (25)

    简单dfs #include<cstdio> #include<cstring> #include<cmath> #include<vector> #i ...

  6. PAT甲题题解-1106. Lowest Price in Supply Chain (25)-(dfs计算树的最小层数)

    统计树的最小层数以及位于该层数上的叶子节点个数即可. 代码里建树我用了邻接链表的存储方式——链式前向星,不了解的可以参考,非常好用: http://www.cnblogs.com/chenxiwenr ...

  7. PAT甲级——1106 Lowest Price in Supply Chain(BFS)

    本文同步发布在CSDN:https://blog.csdn.net/weixin_44385565/article/details/90444872 1106 Lowest Price in Supp ...

  8. PAT 甲级 1106 Lowest Price in Supply Chain

    https://pintia.cn/problem-sets/994805342720868352/problems/994805362341822464 A supply chain is a ne ...

  9. PAT 1106 Lowest Price in Supply Chain

    A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone invo ...

随机推荐

  1. PHP编译安装时常见错误及解决办法,大全

    1.   configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution ...

  2. Jmeter文件目录,功能简介

    1.Jmeter文件目录:1)bin文件: Jmeter启动:bin/jmeter.bat Jmeter日志文件:jmeter.log Linux的启动文件:Jmeter.sh Jmeter系统配置文 ...

  3. 剑指offer 33 把数组排成最小的数

    错误代码 class Solution { public: int FindGreatestSumOfSubArray(vector<int> array) { int length = ...

  4. Python 爬虫的工具列表

    这个列表包含与网页抓取和数据处理的Python库 网络 通用 urllib -网络库(stdlib). requests -网络库. grab - 网络库(基于pycurl). pycurl - 网络 ...

  5. System.Web.UI.Page

    mdsn:点击查看此类介绍 git:   点击查看封装方法   消息弹框,消息弹框跳转,自定义脚本信息 定义:表示一个从托管 ASP.NET Web 应用程序的服务器请求的 .aspx 文件(也称为 ...

  6. 微信小程序之setData原理以及几点关于小程序的吐槽

    小程序不方便之处: 1: 想做个获取列表中每个item所在的对应滚动条的高度在哪里,或者元素本身的高度也不好获取,极其不方便,网上看的别人做的滚动条相关的,都是写死或者已知的item高度,目前没找到正 ...

  7. vs code配置c/c++调试环境+mingw+windows

    目录 1.安装codeblocks 2.配置mingw环境变量 3.配置.vscode文件夹的json文件 ref 1.安装codeblocks 我已经安装过vscode和c++扩展插件,现在需要g+ ...

  8. Git学习第一天--安装Git和创建版本库

    Windows上安装Git msysgit是Windows版的Git,从https://git-for-windows.github.io下载(备份:百度网盘),然后按默认选项安装即可. 安装完成后, ...

  9. datatable常用设置

    bSort: false, // 是否排序功能 bFilter: false, // 过滤功能 bPaginate: true, // 翻页功能 bInfo: true, // 页脚信息 bProce ...

  10. linux 开机自启动 Tomcat

    1.修改脚本文件rc.local:vim /etc/rc.d/rc.local 这个脚本是使用者自定的开机启动程序,可以在里面添加想在系统启动之后执行的脚本或者脚本执行命令 2.添加如下内容: exp ...