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:Reorder List(重序链表)
Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You must do thi ...
- JQuery遍历CheckBox踩坑记
$("#checkbox_id").attr("checked"); //获取一个CheckBox的状态(有没有被选中,返回true/false) $(&quo ...
- HashMap resize代码详解(二)
关于其中的resize方法如下: final Node<K,V>[] resize() { Node<K,V>[] oldTab = table; int oldCap = ( ...
- Flask-WTF表单
Web表单 Web 表单是 Web 应用程序的基本功能. 它是HTML页面中负责数据采集的部件.表单有三个部分组成:表单标签.表单域.表单按钮.表单允许用户输入数据,负责HTML页面数据采集,通过表单 ...
- 左边的div导航根据右部div内容的高自动调整
div结构如下: <div class="mainbody"> <div class="left">导航</div> < ...
- java项目添加到Tomcat中运行-(项目转换为Dynamic Web Project)
当在eclipse中建了一个java project项目希望他运行在Tomcat中时: 在项目上右键单击,选择 Properties: 在左侧选择 Project Facets,单击右侧的 ”Conv ...
- ES6-块级作用域绑定-let和const
一.var声明及变量提升机制 var声明,无论实际上在哪里声明,都会被当做在当前作用域顶部声明的变量,这就是变量提升机制. 二.块级声明 块级声明用于声明在指定块的作用域之外无法访问的变量.块级作用域 ...
- 【剑指offer】栈的压入弹出序列,C++实现(举例)
原创文章,转载请注明出处! 本题牛客网地址 博客文章索引地址 博客文章中代码的github地址 1.题目 输入两个整数序列,第一个序列表示栈的压入顺序,请判断第二个序列是否为第一个序列的出栈序列.注意 ...
- 2017年 ACM Journal Latex templates 新模板生成 acmart.cls 文件
假定你的文稿在:/user/acmart-master那么cd /user/acmart-masterlatex acmart.ins最后可得到acmart.cls.
- CSS琐碎[1]
(1)letter-spacing 设置字符间局,用长度指定(百分比兼容性不好) 没有间距 间距6px API:http://gucong3000.github.io/css-book/propert ...